nitro
nitro copied to clipboard
[vite] server routes return handler file contents instead of proper response during `vite dev`
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.
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.