使用Nginx时ng serve显示空白页

时间:2019-01-19 07:07:30

标签: angular nginx reverse-proxy

我正在从事Angular 7项目。我已经开始ng服务,它正在http://localhost:4200上投放。标签设置为。

我已将nginx配置为反向代理,如下所示:

location / {
        proxy_pass http://localhost:4200;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
}

导航到http://localhost时,我得到一个空白页,并在控制台中看到以下消息:

Loading failed for the <script> with source “http://localhost/runtime.js”
Loading failed for the <script> with source “http://localhost/polyfills.js”
Loading failed for the <script> with source “http://localhost/styles.js”
Loading failed for the <script> with source “http://localhost/vendor.js”
Loading failed for the <script> with source “http://localhost/main.js”.

当我导航到http://localhost:4200

时,应用程序按预期工作

我在做什么错了?

0 个答案:

没有答案