Closed ivanhofer closed 1 year ago
Workaround for now:
/api
=> /api/root
/api/child
can stay
or.
in the route
/api
=> /api.json
/api/child
=> /api/child.json
FWIW we call this out in the docs already: https://kit.svelte.dev/docs/page-options#prerender-route-conflicts
I don't think there's any way around this. We can't just change the name of the saved files, because if /api
is saved as <output>/api.json
, someone accessing /api
directly (whether via a fetch
in their app, or by typing it into the URL bar) will get a 404. .html
is the exception (and even then, some webservers need extra configuration before treating <output>/foo.html
as /foo
).
All we can do is detect the error and guide the developer towards a resolution
Thanks for adding the error message and guiding to the docs! I haven't seen this section before.
Describe the bug
When
prerender
set totrue
and a+page.ts
file makes afetch
request, the response of that request get's written to disk. But it does so without a file ending. So when making a request to/api
and/api/child
the first response get's saved as/api
(file) and when it tires to save the second response, an error get's thrown becauseSvelteKit
tries to create the/api
folder to save the/api/child
file.Reproduction
https://stackblitz.com/edit/sveltejs-kit-template-default-vrpjqd
Running
npm run build
will throw an error.Logs
No response
System Info
Severity
blocking an upgrade
Additional Information
No response