Nginx跨域配置 Access-Control-Allow-OriginAccess-Control-Allow-HeadersAccess-Control-Allow-MethodsAcc
配置服务器可以接受哪些请求源(Origin),即接受哪些跨域的请求,即哪些其他的域可以访问自身的内容。可单独指定可访问自身的域,也可配置 * ,允许所有跨域请求
跨域允许携带的特殊头信息字段,如 Content-Type,Content-Length,Authorization,Accept,X-Requested-With,可单独配置,也可配置 * ,允许所有
跨域允许的请求方法或者说Http动词,如 PUT,POST,GET,DELETE,OPTIONS。可单独配置,也可配置 * ,允许所有
是否允许跨域使用cookies,配置 true 允许
location / { # 这里配置单个代理跨域,跨域配置add_header 'Access-Control-Allow-Origin' 'http://localhost:8080';#此为单独允许http://localhost:8080的请求跨域访问自身add_header 'Access-Control-Allow-Credentials' 'true';add_header 'Access-Control-Allow-Methods' 'PUT,POST,GET,DELETE,OPTIONS';add_header 'Access-Control-Allow-Headers' 'Content-Type,Content-Length,Authorization,Accept,X-Requested-With';}
也可配置为:
location / { # 这里配置单个代理跨域,跨域配置add_header 'Access-Control-Allow-Origin' *;add_header 'Access-Control-Allow-Credentials' 'true';add_header 'Access-Control-Allow-Methods' *;add_header 'Access-Control-Allow-Headers' *;}
参考:
Nginx配置跨域(CORS)
https://blog.csdn.net/weixin_44273388/article/details/124206129
HTTP的8种请求方式
https://blog.csdn.net/weixin_45659878/article/details/107927883
来源地址:https://blog.csdn.net/qq_44659804/article/details/128855619
--结束END--
本文标题: nginx跨域配置
本文链接: https://www.lsjlt.com/news/387766.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-04-29
2024-04-29
2024-04-29
2024-04-18
2024-04-17
2024-04-11
2024-04-08
2024-04-08
2024-04-03
2024-03-15
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0