0

Starting server as

ng serve --proxy-config proxy.conf.json

the content of prox.conf.json

{
  "/api": {
    "target": "http://url.com",
    "secure": false,
    "pathRewrite": {"^/api" : ""}
  }
}

I'm, sure the proxy.conf.json file is been picked up, cause if I give wrong file path it errors out, but when the server starts, in the log there is no Proxy created: /api -> type message logs ... Why ? Also the proxy not working as apis are getting 404.

N.B.

this is ng serve server log

ng serve --proxy-config proxy.conf.json
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **

Date: 2019-01-22T20:55:01.248Z
Hash: 5d28d291a6df6ed34917
Time: 9615ms
chunk {main} main.js, main.js.map (main) 30.3 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 236 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.08 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 179 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 6.51 MB [initial] [rendered]
ℹ 「wdm」: Compiled successfully.
sapy
  • 8,952
  • 7
  • 49
  • 60

2 Answers2

0

I tried with the following configuration.

   {
      "/api": {
        "target": "http://url.com",
        "secure": false,
        "changeOrigin": true
      }
    }
0

Try it:

{
  "/api": {
    "target": "http://api.yourdomain.com",
    "secure": false,
    "changeOrigin": true,
    "logLevel": "info" 
  }
}
HM Tanbir
  • 990
  • 12
  • 30