Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/439.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 当应用程序从nginx代理传递中服务时,相对路径问题_Angularjs_Node.js_Nginx - Fatal编程技术网

Angularjs 当应用程序从nginx代理传递中服务时,相对路径问题

Angularjs 当应用程序从nginx代理传递中服务时,相对路径问题,angularjs,node.js,nginx,Angularjs,Node.js,Nginx,我有一个angular js应用程序,它是从运行locahost:8050的节点服务器提供服务的。当我点击localhost:8050时,它运行良好。但我希望该请求将通过代理发送到localhost:8050,因此我已经设置了nginx,如下所示: server { listen 80; server_name ingl.sorc.com; location /portal/gen/ { proxy_pass http://localhost:8050;

我有一个angular js应用程序,它是从运行locahost:8050的节点服务器提供服务的。当我点击localhost:8050时,它运行良好。但我希望该请求将通过代理发送到localhost:8050,因此我已经设置了nginx,如下所示:

server {
    listen 80;
    server_name ingl.sorc.com;
    location /portal/gen/ {
        proxy_pass http://localhost:8050;    
        }
} 
并在etc hosts文件中输入127.0.0.1 ingl.sorc.com条目

所以当我点击ingl.sorc.com/portal/gen/这个URL时,它会显示一个空白页面。它显示空白页,因为它试图从“”和“”获取css和js文件,这些文件最终不存在于特定路径中

我正在使用grunt构建angular应用程序。在index.html中构建应用程序后,使用相对路径将css和js添加到页面中。例如:

<link rel="stylesheet" href="styles/main.46a5c195.css">
<script src="scripts/vendor.7925e705.js"></script>


请帮帮我。我不知道如何解决这个问题。

您需要为样式添加有效条目。试试像这样的东西

server {
    listen 80;
    server_name ingl.sorc.com;
    location /portal/gen/ {
        proxy_pass http://localhost:8050;    
    }
    location /styles/ {
        # you'll have to find the right path 
        proxy_pass http://localhost:8050/styles; 
    }    

}