如何解决NGINX代理通过后React应用未加载
我有一个NGINX服务器,一个Nodejs后端和2个React应用程序,一个是我构建的常规前端并充当Nginx的静态内容,另一个是运行在端口8080上的第三方仪表板服务[react app]。Nginx conf设置为将前端React应用程序作为静态文件提供,而另一个React应用程序是我要代理传递的第三方仪表板服务。但是react应用[仪表板服务]未加载。
server {
listen 80;
listen [::]:80;
server_name task-manager.eastus.cloudapp.azure.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name task-manager.eastus.cloudapp.azure.com;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
# certs sent to the client in SERVER HELLO are concatenated in ssl_certificate
ssl_certificate /etc/letsencrypt/live/task-manager.eastus.cloudapp.azure.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/task-manager.eastus.cloudapp.azure.com/privkey.pem;
## node js server running on port 4000
location /api/ {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass "http://localhost:4000/";
}
##second react app running on port 8080
location /explorer/{
proxy_pass "http://localhost:8080/";
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
以下是加载URL时在控制台上出现的错误。
Uncaught SyntaxError: Unexpected token '<'
预先感谢
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。