nitrojs / nitrojs/nitro

Headers with underscores (e.g. key_login) are accessible in dev but missing in build mode

Open
#4,192 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug v3
Dominant language
TypeScript
Stars
11.2k
Forks
899
Avg merge
2d 24m
Merged PRs (30d)
40

Description

Environment

Nitro version: 3.0.260311-beta
Node version: v24.5.0
Package manager: yarn

Reproduction

export default defineEventHandler((event) => {
const headers = getHeaders(event)

console.log('headers:', headers)

return {
key_login: headers['key_login']
}
})

Describe the bug

Headers containing underscores (e.g. key_login) behave inconsistently between dev and build modes.

In dev mode, the header can be read normally.

However, after building the project and running the production server, the same header cannot be retrieved from the headers object.

This leads to different runtime behavior between development and production environments.

Additional context

The issue appears to only affect headers containing underscores (_)
Headers without underscores appear to work normally
The same request and handler code are used in both dev and build modes

Logs

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the provided defineEventHandler and getHeaders example in both dev and build modes, using headers with and without underscores. Compare the resulting headers objects and trace the production build's request-header handling. Done means underscore-containing headers such as key_login are accessible consistently in both modes, with regression coverage for the difference.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.