使用代理配置托管angular应用程序

使用代理配置托管angular应用程序,angular,nginx,configuration,Angular,Nginx,Configuration,我正在使用angular构建一个字典应用程序,它使用牛津字典API来检索数据。在开发环境中,我使用proxy.conf.json转发请求 { "/oxfordapi": { "target": "https://od-api.oxforddictionaries.com/api/v1/entries/en/", "secure": true, "changeOrigin": true, "logLevel": "debug", "headers": { "Accept

我正在使用angular构建一个字典应用程序,它使用牛津字典API来检索数据。在开发环境中,我使用proxy.conf.json转发请求

{
"/oxfordapi": {
  "target": "https://od-api.oxforddictionaries.com/api/v1/entries/en/",
  "secure": true,
  "changeOrigin": true,
  "logLevel": "debug",
  "headers": {
    "Accept": "application/json",
    "app_id": "cb35ef20",
    "app_key": "603be016c344650e6d8c1da15330f7af"
  },
  "pathRewrite": {"^/oxfordapi" : ""}
 }
}
当我为生产版本构建应用程序并将其托管在我的nginx服务器上时,当我尝试从服务器获取数据时,它总是出错。 我已经阅读了nginx服务器配置中的proxy_pass,但我是nginx服务器的新手,请帮助我解决此问题。如果可能,请提供此问题的完整服务器配置。提前感谢您尝试以下代码:-

server {

      root /home/ubuntu/test/dist/demo; 
      index index.html; 
      server_name test.vivekm.me; 

      location /oxfordapi {
        proxy_pass https://od-api.oxforddictionaries.com/api/v1/entries/en/;
        proxy_set_header Accept application/json;
        proxy_set_header app_id $http_app_id;
        proxy_set_header app_key $http_app_key;
      }

      location / {
            try_files $uri $uri/ /index.html;
      }
    }

你能分享你当前的NGINX配置吗?
server{root/home/ubuntu/test/dist/demo;index index.html;server_name test.vivekm.me;location/{try_files$uri$uri//index.html;}
我还需要发送头文件
“headers”:{“Accept:”application/json”,“app_id:“cb35ef20”,“app_key”:“603be016c344650e6d8c1da15330f7af”}
请尝试更新的答案并让我知道结果。感谢直到我得到错误,因为身份验证参数丢失。从前端发送的
app_id
app_key
是否在proxy.conf.json中设置了它们