Closed djsuprin closed 7 years ago
Hi Vladimir.. yes, i would like this feature - if it is currently not working i'd like to fix it. Could you send me a link to a gist or some code i can use to reproduce this issue? With a failing test case it would be easier for me to diagnose and repair.
Hi Lloyd,
I've just realized that it is not a big issue. All the headers that are sent with a request to a local-web-server instance are also proxied to the remote resource. I have installed a Chrome extension to modify request headers and now I can add Authorization header on the fly. However, I think that it would be really nice to implement an extra configuration for "rewrite" section, so besides "from" and "to" properties one could also specify a list of HTTP headers to be sent to the remote resource.
Sorry for wasting your time. Local-web-server is a great tool! :+1:
Kind regards, Vladimir
I think that it would be really nice to implement an extra configuration for "rewrite" section, so besides "from" and "to" properties one could also specify a list of HTTP headers to be sent to the remote resource.
that's a good idea, I will add that at some point.
Thanks, let me know if you have any more issues.
due to corporate proxy authentication, would be really great
yes, this feature is next on the list once v2 is done.. re-opening.
In local-web-server v2 (work in progress), all headers from the initial request are included in the proxy request.
So, let's say you have this config:
{
"rewrite": [
{
"from": "/users/*",
"to": "http://example-api.com/users/$1"
}
],
}
If your local server receives this request:
GET /users/ HTTP/1.1
Host: 127.0.0.1:8000
Connection: keep-alive
User-Agent: Mozilla/5.0
Content-Type: application/json
Accept: application/json
X-Requested-With: XMLHttpRequest
Referer: http://127.0.0.1:8000/
Accept-Encoding: gzip, deflate, sdch, br
Accept-Language: en-US,en;q=0.8
Cookie: JSESSIONID=OSyd08J4xYKryHhHHCzh1OPJ
Then the proxy request sent to the remote server will look like this:
GET /users/ HTTP/1.1
Host: example-api.com # <-- The only difference in the proxy request.
Connection: keep-alive
User-Agent: Mozilla/5.0
Content-Type: application/json
Accept: application/json
X-Requested-With: XMLHttpRequest
Referer: http://127.0.0.1:8000/
Accept-Encoding: gzip, deflate, sdch, br
Accept-Language: en-US,en;q=0.8
Cookie: JSESSIONID=OSyd08J4xYKryHhHHCzh1OPJ
Notice that only the Host
header is changed (to make it seem to the remote server that it received a valid, direct request). Therefore, all headers included in the initial request are included in the proxy request. If you want additional headers to be sent to the remote server, then add them to the initial request.
Does this behaviour satisfy your use cases? @raDiesle @djsuprin
You can test the behaviour described above in v2 which is in progress and available for preview.
fixed and released in v2.0.0
Hello!
Is it possible to proxy request HTTP headers? For instance, it would be great if I could send basic authentication header to test front-end with a real REST API. Adding login and password to URL in plain text does not work.
Thanks for any information.
Kind regards, Vladimir