Skip to content

invalid connection header when using nginx proxy #1074

@ahoiroman

Description

@ahoiroman

Environment

  • Operating System: Darwin
  • Node Version: v22.20.0
  • Nuxt Version: 4.1.3
  • CLI Version: 3.29.1
  • Nitro Version: 2.12.6
  • Package Manager: pnpm@10.17.1
  • Builder: -
  • User Config: modules, devtools, css, content, mdc, compatibilityDate, nitro, vite, eslint, i18n
  • Runtime Modules: @nuxt/eslint@1.9.0, @nuxt/image@1.11.0, @nuxt/ui@4.0.1, @nuxtjs/i18n@10.1.0, @nuxt/content@3.7.1
  • Build Modules: -

Reproduction

Describe the bug

When I use a proxy (NGINX) to connect to my Nuxt project via https://web.example.test, I am getting "An error has occurred" . Changing https:// to http:// does not resolve the problem.

Calling http://localhost:3000 works fine.

Additional context

Exception

[ode_modules/.pnpm/youch-core@0.3.3/node_modules/youch-core/build/index.js](vscode://file//Users/ahoi/Entwicklung/Nuxt/example-frontend/node_modules/.pnpm/youch-core@0.3.3/node_modules/youch-core/build/index.js:128)
in #normalizeError
at line 128:19

      return source;
    }
    if (typeof source === "object" && source && "message" in source && "stack" in source) {
      return source;
    }
    const error = new Exception(JSON.stringify(source));
    error.help = 'To get as much information as possible from your errors, make sure to throw Error objects. See <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error</a> for more information.';
    return error;
  }

where const error = new Exception(JSON.stringify(source)); is highlighted.

Request

host	web.example.test
x-real-ip	127.0.0.1
x-forwarded-for	127.0.0.1
x-forwarded-proto	https
x-client-verify	SUCCESS
x-nginx-proxy	true
connection	upgrade
sec-fetch-dest	document
user-agent	Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0.1 Safari/605.1.15
accept	text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
sec-fetch-site	none
sec-fetch-mode	navigate
accept-language	de-DE,de;q=0.9
priority	u=0, i
accept-encoding	gzip, deflate, br

Logs

[6:10:02 PM]  ERROR  Fetch handler error: fetch failed

    at node:internal/deps/undici/undici:13510:13
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)                                                    
    at async Server.<anonymous> (node_modules/.pnpm/@nuxt+cli@3.29.1_magicast@0.3.5/node_modules/@nuxt/cli/dist/chunks/dev.mjs:115:27)

  [cause]: invalid connection header

      at processHeader (node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/core/request.js:399:13)                              
      at new Request (node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/core/request.js:187:11)                                
      at [dispatch] (node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/dispatcher/client.js:299:21)                            
      at Client.dispatch (node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/dispatcher/dispatcher-base.js:153:29)              
      at [dispatch] (node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/dispatcher/pool-base.js:157:28)                         
      at Pool.dispatch (node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/dispatcher/dispatcher-base.js:153:29)                
      at [dispatch] (node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/dispatcher/agent.js:122:23)                             
      at Agent.dispatch (node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/dispatcher/dispatcher-base.js:153:29)               
      at node:internal/deps/undici/undici:11144:55
      at new Promise (<anonymous>)
      at dispatch (node:internal/deps/undici/undici:11144:16)
      at httpNetworkFetch (node:internal/deps/undici/undici:11041:73)                                                                 
      at httpNetworkOrCacheFetch (node:internal/deps/undici/undici:10927:39)                                                          
      at httpFetch (node:internal/deps/undici/undici:10760:43)
      at schemeFetch (node:internal/deps/undici/undici:10677:18)
      at node:internal/deps/undici/undici:10522:26
      at mainFetch (node:internal/deps/undici/undici:10541:11)
      at fetching (node:internal/deps/undici/undici:10489:7)
      at fetch (node:internal/deps/undici/undici:10358:20)
      at fetch (node:internal/deps/undici/undici:13508:10)
      at fetch (node:internal/bootstrap/web/exposed-window-or-worker:75:12)                                                           
      at fetchAddress (node_modules/.pnpm/@nuxt+cli@3.29.1_magicast@0.3.5/node_modules/@nuxt/cli/dist/chunks/dev.mjs:75:12)           
      at Server.<anonymous> (node_modules/.pnpm/@nuxt+cli@3.29.1_magicast@0.3.5/node_modules/@nuxt/cli/dist/chunks/dev.mjs:115:33)    
      at Server.emit (node:events:530:35)
      at parserOnIncoming (node:_http_server:1153:12)
      at HTTPParser.parserOnHeadersComplete (node:_http_common:117:17)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions