我开发了一个角度应用程序,它使用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。如何实现这一点?到处搜索但没有帮助。代理配置文件的代码仅用于开发模式,但如何使其在生产模式下工作?
任何形式的帮助都非常感谢。