Nginx解决跨域问题
跨域问题
解决跨域问题(CORS跨域资源共享)
Nginx的解决方案
1.在nginx.conf中配置文件中的server指令块下面配置以下内容,之后就可以解决跨域问题了
server {
listen 88;
server_name localhost;
# 允许跨域请求的域,*代表所有
add_header 'Access-Control-Allow-Origin' *;
# 允许带上cookie请求
add_header 'Access-Control-Allow-Credentials' 'true';
# 允许请求的方法,比如 GET/POST/PUT/DELETE
add_header 'Access-Control-Allow-Method' *;
# 允许请求的header
add_header 'Access-Control-Allow-Headers' *;
location / {
root html;
index index.html index.htm;
}
}
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/176807.html原文链接:https://javaforall.net
