参考链接 : https://medium.com/@hariomvashisth/cors-on-nginx-be38dd0e19df
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| server { listen 80; server_name api.test.com;
location / {
# Simple requests if ($request_method ~* "(GET|POST)") { add_header "Access-Control-Allow-Origin" *; }
# Preflighted requests if ($request_method = OPTIONS ) { add_header "Access-Control-Allow-Origin" *; add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS, HEAD"; add_header "Access-Control-Allow-Headers" "Authorization, Origin, X-Requested-With, Content-Type, Accept"; return 200; }
.... # Handle request .... } }
|