如何通过配置请求头解决跨域?

本地vue项目localhost访问http://abc.com下的api,产生跨域。
在服务端配置Access-Control-Allow-Origin:*后,因为要携带cookie,浏览器提示不能配置成*
所以我就将我本地localhost的地址配置到Access-Control-Allow-Origin:http://localhost:9538

但是现在浏览器有给我这个提示Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9538' is therefore not allowed access.

我查了下这个的意思大致是非简单请求预检请求没通过,这个要怎么解决哦?有大佬指点下吗

阅读 3.4k
2 个回答

allow-methods也需要配置

推荐问题