如何在托管角度应用程序时设置nginx为api请求配置代理调用?

时间:2018-06-02 08:40:17

标签: angular nginx

我开发了一个角度应用程序,它使用proxy.conf文件来调用api请求:

{
    "/oxfordapiauto": {
      "target": "https://od-api.oxforddictionaries.com/api/v1/search/",
      "secure": true,
      "changeOrigin": true,
      "logLevel": "debug",
      "headers": {
        "Accept": "application/json",
        "app_id": "933daf11",
        "app_key": "34bef88a5c41a2d98f35d8783c887ec0"
      },
      "pathRewrite": {"^/oxfordapiauto" : ""}
    },

    "/oxfordapi": {
      "target": "https://od-api.oxforddictionaries.com/api/v1/entries/en/",
      "secure": true,
      "changeOrigin": true,
      "logLevel": "debug",
      "headers": {
        "Accept": "application/json",
        "app_id": "933daf11",
        "app_key": "34bef88a5c41a2d98f35d8783c887ec0"
      },
      "pathRewrite": {"^/oxfordapi" : ""}
    }

  }


 Here is the full code:https://github.com/saisreereddy/sample_personal_dictionary

但是当我使用nginx在ng-build之后部署应用程序时,它不会调用api。如何实现这一点?到处搜索但没有帮助。代理配置文件的代码仅用于开发模式,但如何使其在生产模式下工作?

任何形式的帮助都非常感谢。

0 个答案:

没有答案