跨域配置过多或没有配置

Access to XMLHttpRequest at 'http://oa.sdsoon.cn:8099/project/list?page=1&limit=20' from origin 'http://127.0.0.1:8020' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains multiple values 'http://127.0.0.1:8020, *', but only one is allowed.

出现这问题有可能是服务器端配置了跨域选项,在代码端也指定了跨域设置导致冲突,去掉一边的配置即可

例如:代码和nginx

代码中查看是不是配置:

header("Access-Control-Allow-Origin: *");

nginx配置有没有配置:

add_header Access-Control-Allow-Origin *;

这两个配置,只要保留一个即可。

发布了89 篇原创文章 · 获赞 32 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/qq_41345773/article/details/101065757