Closed kripod closed 8 months ago
Are they broken only in development (just to understand, obviously this is still very important).
Yes, the issue only occurs in dev mode.
I'll look into it
Hi @kripod, we talked about this internally.
This isn't a bug. We actually fixed that bug, and now the routing behaves consistently. As you set trailingSlash: always
, it's expected that routes should respond to a trailing slash, endpoints too. Essentially, you were leveraging a bug.
I suggest using trailingSlash: ignore
.
We will monitor the situation and see if this bugfix impacts too many users.
@ematipico I think my issue report may have been misunderstood.
Trailing slashes are a valid requirement for most API endpoint URLs, except for the ones which are meant to serve static files, e. g. .png
images. Having to refer to those assets via /something.png/
instead of /something.png
may be outright invalid in production, even when trailing slashes are preferred.
We've been having this issue for months. We have a search.json.ts static file endpoint in the pages dir. In prod we need to not add a trailing slash to the end of the route and in dev we need to make sure there is a trailing slash. It's not an optimal situation.
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
Since
astro@4.1.0
, Static File Endpoints return 404 in development (runningastro dev
) whentrailingSlash: "always"
is set in the Astro config.What's the expected result?
Static File Endpoints should work as they did before merging https://github.com/withastro/astro/pull/9597.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-fy7uro?file=src%2Fpages%2Ftest.json.js
Participation