Nginx解决跨域问题No ‘Access

编程入门 行业动态 更新时间:2024-10-22 12:30:29

<a href=https://www.elefans.com/category/jswz/34/1771256.html style=Nginx解决跨域问题No ‘Access"/>

Nginx解决跨域问题No ‘Access

浏览器控制台报错

Access to XMLHttpRequest at ‘’ from origin
‘’ has been blocked by CORS policy: No
‘Access-Control-Allow-Origin’ header is present on the requested
resource.

解决办法

使用nginx在server块下或location块下为请求添加请求头都可以解决跨域问题。

add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET,POST,DELETE';
add_header 'Access-Control-Allow-Header' 'Content-Type,*';

更多推荐

Nginx解决跨域问题No ‘Access

本文发布于:2024-03-07 20:13:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1718809.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Nginx   Access

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!