因為接口涉及到跨域問題,每次接口請求時都有接近600毫秒是OPTIONS請求浪費的時間,如何優(yōu)化這一過程,例如 nginx 配置跨域直接返回而不經(jīng)過程序處理(php)
1 回答

拉莫斯之舞
TA貢獻1820條經(jīng)驗 獲得超10個贊
跨域也走你本域的ngx?還是你本域的ngx在做跨域的代理?
ngx設置:
if ($request_method = OPTIONS ) {
add_header Access-Control-Allow-Origin "*";
add_header Access-Control-Allow-Methods "POST, GET, PUT, OPTIONS, DELETE";
add_header Access-Control-Max-Age "3600";
add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization";
add_header Content-Length 0;
add_header Content-Type text/plain;
return 200;
}
- 1 回答
- 0 關注
- 1533 瀏覽
添加回答
舉報
0/150
提交
取消