因为接口涉及到跨域问题,每次接口请求时都有接近600毫秒是OPTIONS请求浪费的时间,如何优化这一过程,例如 nginx 配置跨域直接返回而不经过程序处理(php)
1 回答
![?](http://img1.sycdn.imooc.com/5458506b0001de5502200220-100-100.jpg)
拉莫斯之舞
TA贡献1820条经验 获得超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 关注
- 1524 浏览
添加回答
举报
0/150
提交
取消