Uncaught (in promise) Error: Request failed with status code 405
部署页面后,页面可以访问,但是后端数据取不到。 F12 查看报错 405
原因:nginx 的conf 配置,没有做好反向代理
解决方法:修改nginx 配置文件, 然后 重启下服务 nginx -s reload
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 9081;
server_name localhost;
location / {
root /opt/qanda/dist; # 前端工程的目录
index index.html; # 前端页面
try_files $uri $uri/ /index.html;
}
location /gksk/ { # 反向代理到后端工程
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:9080/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}