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.

proxyRes not working

See original GitHub issue

This is my relevant code:

import browserSync   from 'browser-sync'
const bs = browserSync.create()

let server;
bs.init({
  proxy: {
    target: 'localhost:8000',
    proxyRes: [
      (res,req,next) => {
        req.body += 'hello'
        next()
      }
    ]
  },
})

it says next is not a function

Also, it takes forever browsersync to start. There’s only two files to watch, although I don’t even really want browsersync to watch any files, but it takes like 10 - 15 seconds to start

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
zwhitchcoxcommented, Apr 20, 2016

Idk what I did, but it’s working now

Code for anyone needing a fix:

import browserSync   from 'browser-sync'
const bs = browserSync.create()
bs.init({
  proxy: {
    target: 'localhost:8000',
  },
  snippetOptions: {
    rule: {
      match: /.*/i,
      fn: function (snippet, match) {
        return snippet + match
      }
    }
  }
})
0reactions
zwhitchcoxcommented, May 19, 2017

Dude, it’s so long ago, I can’t remember…I pretty much gave up on browser sync cuz so many bugs

Read more comments on GitHub >

github_iconTop Results From Across the Web

typing for proxyRes seems to be incorrect · Issue #407 - GitHub
TypeScript expects proxyRes.headers to be an array of strings. Actual behavior. ✖ uncaughtException (an exception was thrown but not caught) ...
Read more >
onProxyRes of http-proxy-middleware doesn't work for same ...
I'm trying to write a proxy using http-proxy-middleware that modifies the content of the response, and set some headers.
Read more >
http-proxy-middleware - npm
Configure proxy middleware with ease for connect, express, browser-sync and many more. Powered by the popular Nodejitsu http-proxy . GitHub ...
Read more >
node_modules/http-proxy · master - PLMlab
Contributing and Issues; License ... return the response by listening and acting on the proxyRes event ... Listen for the `proxyRes` event on...
Read more >
Reverse proxy - Maapteh - Medium
As always the first version was done in an hour, but then the real problems started. We have to alter the Response header...
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