nuxt / nuxt

The Intuitive Vue Framework.
https://nuxt.com
MIT License
55.14k stars 5.04k forks source link

serverDir not being registered #28695

Closed nunonux closed 3 months ago

nunonux commented 3 months ago

Environment

Reproduction

Github Repo: https://github.com/nunonux/nuxt-serverdir-issue StackBlitz: https://stackblitz.com/edit/github-adnwzy?file=nuxt.config.ts

Describe the bug

When I set the serverDir property in nuxt.config.ts with the value '/src/server', nuxt don't register the routes in the api folder. So, if I send an request for a route in the api folder, I get an 404 request error.

Additional context

Normally I structure my nuxt app as: src/ app/ server/ It has been working great until the nuxt version 1.12.4 and 1.13.0, that's were it breaks my current app.

Logs

No response

stackblitz[bot] commented 3 months ago

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

github-actions[bot] commented 3 months ago

Stackblitz link for the reproduction: Stackblitz

huang-julien commented 3 months ago

Hey :wave: thanks for opening the issue ! It's indeed a bug; It should be relative to the root dir according to the docs. But it's currently relative to your srcDir rn without V4 compatibility.

@danielroe i'll open a PR to fix it. Let me know if we should just correct the doc instead