Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

267
Views
http-proxy-middleware adding custom header

I'm using http-proxy-middleware to setup request proxy from auth service to secured API.

Here I need to add custom header with authenticated user auth ID for every incoming request to the authentication layer. But with following implementation header not adding to the request. Here I've used on.proxyReq,

app.use('/info', auth, createProxyMiddleware({
    target: process.env.BASE_API_URL,
    changeOrigin: false,
    on: {
        proxyReq: (proxyReq, req, res) => {
            console.log(`On Proxy Request ${proxyReq}`);
            proxyReq.setHeader('x-auth-user', 'b05ff410-fbba-11ec-bfce-ddefb9f79237');
        },
        proxyRes: (proxyRes, req, res) => {
            console.log(`On Proxy Response ${proxyRes}`);
        },
        error: (err, req, res) => {
            console.log(`On Error Request ${err}`);
        },
    },
}));
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!