'Angular proxy wildcard not working properly. Only applies to one route
I have created an angular proxy to bypass CORS during development. The problem is, that the proxy seems to only apply to one route and it's not applied to anything else. Is there something aside the proxy config I should be aware of? My backend is located on cloud, separate from my development environment.
Here is the configuration for my proxy:
{
"/api/*": {
"target": "http://x.x.x.x:3000",
"secure": false
}
}
The route that works is /api/content while everything else (such as /api/auth) just gives me the following error:
XHR POST http://localhost:4200/api/auth
Status
404
Not Found
VersionHTTP/1.1
Transferred424 B (148 B size)
Referrer Policystrict-origin-when-cross-origin
Solution 1:[1]
This was kind of a silly mistake on my part caused by the error saying that the route "http://localhost:4200/api/auth" was 404. This made me think that the proxy was not working because in that case i expected the error to be "http://x.x.x.x/auth" being 404. In reality the proxy was working, but the api on the server did not yet have such an end point created to it. The error was fixed after I created the POST api hook for /auth.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Nyoa |
