vue部署服务器后,请求地址统一配置加了‘/api’前缀
要访问三方接口地址:http://10.10.10.25:8080/IntellLinkPf/GetChainSummary
vue的请求多了/api:http://10.10.10.25:8080/api/IntellLinkPf/GetChainSummary
修改nginx代理配置解决:
#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 5024; } 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 8080; server_name 10.10.10.25; #rewrite_log on; 重写url记录日志 #error_log logs/test.log debug; #代理方式 location /api/IntellLinkPf/ { proxy_pass http://202.14.69.26:18720/IntellLinkPf/; #最后增加'/IntellLinkPf/',代理后地址移除了'/api' } #重写方式 location /api/IntellLinkPf/ { rewrite /api/(.*) /$1 break; #移除了'/api',$1表示正则中括号匹配到的串 proxy_pass http://202.14.69.26:18720; } location /QCAPI/ { proxy_pass http://10.10.10.25:50095; } location /render/ { proxy_pass http://119.123.241.169:9035; } location /{ proxy_pass http://10.10.10.25:8166; } } }