首页 > 系统相关 >nginx解决vue跨域问题

nginx解决vue跨域问题

时间:2022-12-06 12:22:06浏览次数:38  
标签:Control vue 跨域 header Access nginx add set proxy

location /epayapi
{
    proxy_pass http://127.0.0.1:7011;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;
    
    add_header X-Cache $upstream_cache_status;
    
add_header 'Access-Control-Allow-Credentials' 'true';
 
add_header Access-Control-Allow-Origin "$http_origin";
 
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,language,os,token,ts,version';
 
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header Cache-Control no-cache;

if ($request_method = 'OPTIONS') {
 
return 204;
 
}           
}

#PROXY-END/testepayapi

 

标签:Control,vue,跨域,header,Access,nginx,add,set,proxy
From: https://www.cnblogs.com/wujf/p/16954887.html

相关文章