Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How set proxy headers in proxy.config.json file for angularcli project

I'm trying to set proxy headers for angularcli. Here's what I have so far in my proxy.config.json file:

"/api": {
    "target": "https://applications.str.coni.com/api",
    "secure": false,
    "logLevel": "debug"

But I haven't had any luck so far, perhaps I'm missing something (probably in another file). Any suggestions would be much appreciated.

like image 874
reddy Avatar asked Apr 24 '17 15:04

reddy


1 Answers

Angular-cli uses http-proxy-middleware https://github.com/chimurai/http-proxy-middleware

there is an option called headers that you can use: https://github.com/chimurai/http-proxy-middleware#http-proxy-option

example:

"/api":
  {
    "target": "https://applications.str.coni.com/api",
    "secure": false,
    "logLevel": "debug",
    "headers": {"host":"www.example.org"}
  }
like image 198
Ahmed Musallam Avatar answered Sep 18 '22 00:09

Ahmed Musallam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!