Search code examples
angularobjectwebpackwebpack-dev-serverhttp-proxy

Angular proxy config for multiple target url


I have a few endpoints like below.

  • abcd/text/data
  • xyz/text/data
  • Pqr/text/data

I am trying to add these in proxy config file as fixing cors error.

For single url it is working fine but for all url it is not working. What should i add object key here? As text/data is common in all url.

Correction after David Gerschcovsky's response.

{

"/text/*" : {

     "secure": false,
     "changeOrigin": true,
     "logLevel": "debug",
     "pathRewrite": {
        "^/text/^": ""
    }

      }

}

How to add multiple entries with same object keys in this scenario?


Solution

  • You are missing some parameters, try something like this:

        {
         "/text/*" : {
    
           "target": "abc"
           "secure": true,
           "changeOrigin": true,
           "pathRewrite": {
            "^/api": ""
             }
           }
        }