之前解决过一次,后来给忘记了,今天又遇到这个问题,现记录一下
修改uni-app的manifest.json文件 - 》源码视图
添加以下代码:
"disableHostCheck" : true //解决127.0.0.1指向其他域名时出现"Invalid Host header"问题
VUE项目遇到此问题也类似解决方案(因为uni-app :一款基于vue的跨平台前端框架)
VUE工程解决方案参考:https://blog.csdn.net/Cookysurongbin/article/details/86077241
以下是我的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 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 80; server_name test.com; client_max_body_size 1000m; location / { proxy_set_header Host $Host; proxy_set_header X-Forward-For $remote_addr; proxy_pass http://127.0.0.1:9090; } location /propese { proxy_set_header Host $Host; proxy_set_header X-Forward-For $remote_addr; proxy_pass http://127.0.0.1:9100/propese; } location /swagger { proxy_set_header Host $Host; proxy_set_header X-Forward-For $remote_addr; proxy_pass http://127.0.0.1:9100/swagger-ui.html; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }
希望能帮助大家,更重要的是避免下次采坑!!!