我已经为我的Angular配置了一个代理到后端的API,如下所示
{
"/api/*": {
"target": "http://localhost:3000",
"secure": false,
"logLevel": "debug",
"changeOrigin": true,
"router": {
"localhost:4200" : "http://localhost:3000",
"http://localhost:4200" : "http://localhost:3000"
}
}
}
<a href="/api/json" color="warn">JSON</a>
那应该是
localhost:4200/api/json
localhost:3000/api/json
,但它不起作用。
使用路由模块时没有路径
{ path: 'api', component: APIRedirectComponent, pathMatch: 'prefix'}
它可以使用配置的代理进行http调用。
text/html
如何设计将返回
application/json
从对后端的调用或简单地代理到后端的响应?