question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

proxyReq provides no parameter

See original GitHub issue

Issue details

The function listed in “proxyReq” is called with no parameter. As the parameter “proxyReq” is empty, the function “proxyReq.setHeader” (as in the example) doesn’t exist and we can’t accept the request.

Steps to reproduce/test case

"proxy": {
    target: "localhost",
    proxyReq: [
        function (proxyReq) {
            // proxyReq.setHeader('X-Special-Proxy-Header', 'foobar');
            console.log(proxyReq.headers);
        }
    ]

Please specify which version of Browsersync, node and npm you’re running

  • Browsersync [ 2.17.0 ]
  • Node [ 4.2.6 ]
  • Npm [ 3.5.2 ]

Affected platforms

  • [ X ] linux
  • windows
  • OS X
  • freebsd
  • solaris
  • other (please specify which)

Browsersync use-case

  • API
  • Gulp
  • Grunt
  • CLI

If CLI, please paste the entire command below

{cli command here}

for all other use-cases, (gulp, grunt etc), please show us exactly how you’re using Browsersync

{Browsersync init code here}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
benjiecommented, Oct 24, 2016

Same issue here; browser-sync seems to change the configuration required to pass-through the Host header quite frequently.

From some source-diving I’ve figured out this solves it (changeOrigin: false):

proxy: {
  target: "http://localhost:" + port,
  proxyOptions: {
    changeOrigin: false
  }
}
0reactions
wibjorncommented, Nov 8, 2022

For anyone who finds themselves here, it seems changeOrigin is no longer a valid option.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Edit POST parameters prior to forwarding to a proxy target and ...
Ok Here's the final solution. The following example allows you to inject POST parameters prior to forwarding to the proxy target.
Read more >
ProxyRequest | Microsoft Learn
Calling ProxyRequest(sipRequestUri) to change request-uri in effect marks the request as routed without providing a request target.
Read more >
mod_proxy - Apache HTTP Server Version 2.4
If set, all requests without session id will be redirected to the BalancerMember that has route parameter equal to this value. retry, 60,...
Read more >
http-proxy-middleware - npm
Providing an alternative way to decide which requests should be proxied; In case you are not able to use the server's path parameter...
Read more >
drachtio API
a Promise if no callback is provided, otherwise a reference to the Srf instance. ... If a function is provided, it will be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found