nuxt-community / proxy-module

The one-liner node.js http-proxy middleware solution for Nuxt 2 using http-proxy-middleware

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Headers names lowercased

mathieucollet opened this issue · comments

Hello everyone,

I have a problem when I set up the proxy.

// Axios
axios: {
  proxy: true,
},

// Proxy
proxy: {
  '/api': {
    target: process.env.NUXT_ENV_BACKEND_API,
    pathRewrite: { '^/api': '/' },
    changeOrigin: false,
  },
},

The names of the Headers (Authorization, Host, etc...) are minuscule and causes errors on the back side which does not find the Headers it expects.

I may be doing a bad manipulation, but I'm lost.

From (expected result):
image

After (with axios proxy true):
image

Hi @mathieucollet

This module uses http-proxy-middleware under the hood, you may want to set preserveHeaderKeyCase: true, see https://github.com/chimurai/http-proxy-middleware#http-proxy-options

Thanks @Atinux for your time you took to answer me.

As you suggested, i tried to add the option preserveHeaderKeyCase: true but it doesn't change back my headers names.

Again, i'm maybe doing something wrong.

Hi. Actually this is NodeJS behavior that makes incoming header names to lowercase since by rfc7230#section-3.2 headers are case-incentive and this behavior allows having duplicate headers with different case. Proxy module option is meant for response handling and it is recommended not changing it to avoid inconsistency.