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

204
Views
Nextjs app with proxy - headers not included in response

I'm proxying requests to an external backend from a Nextjs app and trying to extract an Authorization header from the response using the native fetch library. However the headers in the fetch response are empty even though they are present in the actual response from the server.

Here's the setup in the next.config.js file:

module.exports = {
  async headers() {
    return [
      {
        source: '/api/:path*',
        headers: [
          {
            key: 'Access-Control-Expose-Headers',
            value: '*, authorization',
          },
        ],
      },
    ]
  },
  async rewrites() {
    return [
      {
        source: '/api/:path*',
        destination: `${process.env.NEXT_PUBLIC_BASE_URL}/api/:path*`,
      },
    ]
  },
}

With my limited knowledge of proxies I'm assuming that it's a reverse proxy and the headers are lost in the response back somewhere inside it. I've also tried adding a middleware to try to localize where the headers are being lost without any luck.

Does anyone know where I can configure the headers to be included back from the proxy?

Thanks in advance! :)

about 4 years ago ยท Juan Pablo Isaza
1 answers
Answer question

0

I am reusing a fetcher from react-native and it seems like the method for extracting headers differs. ๐Ÿ˜…

This works using fetch in the browser: response.headers.get('authorization')

In react-native: response.headers.map['authorization']

about 4 years ago ยท Juan Pablo Isaza Report
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!