Reputation: 1011
Im trying to use angular proxy to proxy to my backend server. My server is running on http://localhost:8000 My angular server is running on http://localhost:4200
If the API makes a call to http://localhost:4200/api/bacon. I want it proxied to http://localhost:8000/api/bacon. However I only want calls that start with /api to be proxied.
My proxy.conf.json file looks like this.
{
"/api/*":
{
"target": "http://localhost:8000/api",
"secure": false
}
}
And one of my api calls will look like this. http://localhost:4200/api/yemen
In this case I expect it to be proxied to http://localhost:8000/api/yemen
However it does not seem to be working
Upvotes: 2
Views: 572
Reputation: 31805
The full URL gets forwarded to the target because you didn't use pathRewrite
, then you don't have to write /api
in the target
property.
Also if you want to have more informations next time, you can use logLevel: 'debug'
to see incoming requests and their redirections.
{
"/api": {
"target": "http://localhost:8000",
"secure": false,
"logLevel": "debug"
}
}
Upvotes: 1