Reputation: 1277
I want to use proxy config in angular-cli
this is my file:
{
"/api/server": {
"target": "http://other-site/server",
"secure": false,
"logLevel": "debug",
"pathRewrite": { "^/api/server": "" },
"changeOrigin": true
},
"/api/group": {
"target": "http://other-site/group",
"secure": false,
"logLevel": "debug",
"pathRewrite": { "^/api/group": "" },
"changeOrigin": true
},
"/api/group/activate": {
"target": "http://other-site/group/activate",
"secure": false,
"logLevel": "debug",
"pathRewrite": { "^/api/group/activate": "" },
"changeOrigin": true
}
}
it works for me , but i need a other effective solution ( juste remove pattern /api and concatinate with target , for example;
change "/api/server" to "http://other-site/server" ...etc
i am trying with the code below, but doesn't work
{
"/api": {
"target": "http://other-site/",
"secure": false,
"logLevel": "debug",
"pathRewrite": {"^/api" : ""},
"changeOrigin": true
},
}
Upvotes: 2
Views: 273
Reputation: 4806
use pattern "/api/*" ,Try with this:
{
"/api/*": {
"target": "http://other-site",
"secure": false,
"logLevel": "debug",
"pathRewrite": { "^/api": "" },
"changeOrigin": true
}
}
Upvotes: 2