【发布时间】:2019-12-02 22:59:28
【问题描述】:
我有一个 reactjs 前端,它通过 rest 调用从 spring boot 后端获取数据。
在本地运行代码如下:
axios.defaults.baseURL = 'http://localhost:8080/api';
axios.get('/devices').then((resp) => {
this.setState({devices: resp.data});
}).catch(() => {
console.log('Failed to retrieve device details');
});
当我构建代码以使用 npm run build 进行部署时,我仍然将 localhost 作为 url。
如何构建它以便在本地开发它使用 localhost 但部署它使用不同的 url?
一旦我在 Azure 中,我将拥有一个前端和多个后端,需要根据谁登录。
如何配置 API 管理层以根据谁登录(使用 AD 进行身份验证)将调用路由到正确的后端?
由于我使用 APIM 进行路由,baseURL 应该是什么?
【问题讨论】: