Skip to content

How do I generate custom response when proxy error #862

Answered by ColinFay
ColinFay asked this question in Q&A
Discussion options

You must be logged in to vote

I just found the answer to my question, I wasn't looking into the doc of the correct version.

Here it is for v2

const { createProxyMiddleware } = require('http-proxy-middleware');

console.log(Options)

require('express')().use(
  '/',
  createProxyMiddleware({
    target: 'http://sc_rstudio/',
    changeOrigin: true,
    logLevel: 'debug',
    onError: (err, req, res) => {
      console.log("pouet")
      res.send('<h1>Something went wrong.</h1>');
    },
  })
).listen(3000);

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ColinFay
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant