猿问

如何优化跨域请求时OPTIONS的请求速度(NGINX)

因为接口涉及到跨域问题,每次接口请求时都有接近600毫秒是OPTIONS请求浪费的时间,如何优化这一过程,例如 nginx 配置跨域直接返回而不经过程序处理(php)

元芳怎么了
浏览 1525回答 1
1回答

拉莫斯之舞

跨域也走你本域的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; }
随时随地看视频慕课网APP
我要回答