客户马上要看项目了,10多G的文件还在老服务器上,再一看前端路径竟然也全是写死的,感觉死定了。
这时候可以使用nginx反向代理简单处理一下
location /file/ {
root /home/xx/;
index index.html;
# 添加 CORS 头部以允许特定来源的请求
add_header 'Access-Control-Allow-Origin' 'http://{新服务器ip}:10008';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
# 处理预检请求 (OPTIONS)
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' 'http://{新服务器ip}:10008';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
}