Custom fetch server 404 responses are discarded

Open
#3,900 7 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Start with the custom server entry point shown in the StackBlitz reproduction, server/server.ts, and compare its fetch handling with the Vite and Nitro configuration. Reproduce the request that returns a 404 Response; done means that response is preserved instead of being discarded and handled by the frontend.

Written by the indexing model from the issue text.

Description

documentation v3
Environment
  • nitro@3.0.1-alpha.1
  • vite@7.3.0
// vite.config.ts
import { nitro } from 'nitro/vite';
import { defineConfig } from 'vite';

export default defineConfig({
  plugins: [nitro()],
});
// nitro.config.ts
export default defineNitroConfig({
  serverDir: 'server',
});
Reproduction

StackBlitz

Describe the bug

When using Vite and a custom server.ts with fetch, if the fetch returns a 404 Response, it is discarded and the request is handled by the frontend

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

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.

More from nitrojs/nitro

All issues in nitrojs/nitro

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.