阅读:87回复:0
nginx部署后前端post请求出现405错误解决问题复盘: POST http://192.168.131.160/api/auth/login 405 (Not Allowed) 解决方式: location/{ root /www/web/nginx/html; index index.html index.htm; try files $uri $uri/ /index.html; add_header Access-Control-Allow-Origin * always; error page 405 =200 http://localhost:18080$request_uri; } 或者: location / { root /www/web/nginx/html; try_files $uri $uri/ /index.html; index index.html index.htm; error_page 405 =200 @405; #405页面处理 } #加入下面代码 location @405 { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #ip为后端服务地址:端口 proxy_pass http://localhost:18080$request_uri ; } |
|