nginx解决前端项目跨域
【代码】nginx解决前端项目跨域。
·
nginx 解决前端项目的跨域问题
server {
listen 8090;
server_name http://192.168.0.167; # 前端请求的服务地址
location / {
add_header Access-Control-Allow-Origin '*' always;
proxy_set_header origin 'http://192.168.0.233:8085'; # 后台的服务地址
add_header Access-Control-Allow-Headers '*';
add_header Access-Control-Allow-Methods '*';
add_header Access-Control-Allow-Credentials 'true';
if ($request_method = 'OPTIONS') {
return 204;
}
proxy_pass http://192.168.0.233:8085/; # 后台的服务地址
}
}
nginx 映射磁盘目录(windows)
server {
listen 9701;
server_name localhost;
location / {
root D:/HFCC_WEB/mapImg;
autoindex on;
}
}
更多推荐
所有评论(0)