Angular | Receiving index.html when using proxy

23 Views Asked by At

Im learning Angular, and when i try to use proxy, still getting index.html

I am using proxy as below

{
  "/api/*": {
    "target": "http://localhost:8080/v1/api/playground",
    "secure": false,
    "pathRewrite": {
      "^/api": ""
    },
    "changeOrigin": true,
    "logLevel": "debug"
  }
}

And My request is as below where sending request where playgroundId is uuid but I am still getting index.html as response

private apiUrl = '/api/playground/';
const response = await fetch(this.apiUrl + this.playgroundId);

When I am trying to send another request as below, I am getting json in response.

private apiUrl = '/api/playgrounds';
const response = await fetch(this.apiUrl);

` it returning json in response.

I checked logs in server, and in case of 1 request, server do not receives it, but in case of 2, server do receive request.

Any help in this is appreciated

!! I DONT WANT TO CHANGE CORS POLICY ON SERVER SIDE NOW !!

0

There are 0 best solutions below