解决 nginx 跨域 问题
文章目录
在nginx的配置文件中增加:
location / {
add_header Access-Control-Allow-Origin $http_origin;
add_header Access-Control-Allow-Methods 'GET,POST,OPTIONS';
add_header Access-Control-Allow-Credentials true;
add_header Access-Control-Allow-Headers *;
add_header Access-Control-Max-Age 1728000;
if ($request_method = 'OPTIONS') {
return 204;
}
}
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论