nitro icon indicating copy to clipboard operation
nitro copied to clipboard

[vite] server routes return handler file contents instead of proper response during `vite dev`

Open alan-agius4 opened this issue 4 months ago • 1 comments

Environment

Node: 22.18.0 nitro-nightly: 3.0.0-20250717-115429.740761af

Reproduction

In https://github.com/nitrojs/vite-examples/tree/main/examples/basic-service run the below to create a simple server route.

$ mkdir api
touch api/story.ts
echo "export default defineEventHandler(event => 'Hello')" > api/story.ts

$ vite dev

In another terminal run

curl http://localhost:5174/api/story
export default defineEventHandler((event) => "Hello");

//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0b3J5LnRzIl0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBkZWZhdWx0IGRlZmluZUV2ZW50SGFuZGxlcihldmVudCA9PiAnSGVsbG8nKVxuIl0sIm1hcHBpbmdzIjoiQUFBQSxlQUFlLG1CQUFtQixXQUFTLE9BQU87Ii

Describe the bug

When using vite dev server routes return the transformed handler contents.

Additional context

This is not an issue with vite build.

alan-agius4 avatar Aug 27 '25 11:08 alan-agius4

Thanks for report. This is known issue currently. (with vite plugin, only service entries like server.ts work and vite takes over other routes) it will be fixed.

pi0 avatar Aug 27 '25 11:08 pi0