Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static File Endpoints broken with trailingSlash: "always" in development #10149

Closed
1 task
kripod opened this issue Feb 17, 2024 · 6 comments
Closed
1 task
Assignees
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) feat: dev Related to `astro dev` CLI command (scope) regression

Comments

@kripod
Copy link

kripod commented Feb 17, 2024

Astro Info

Astro                    v4.4.0
Node                     v20.10.0
System                   macOS (arm64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations             astro-icon
                         @astrojs/mdx
                         @astrojs/sitemap
                         @astrojs/tailwind

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Since [email protected], Static File Endpoints return 404 in development (running astro dev) when trailingSlash: "always" is set in the Astro config.

What's the expected result?

Static File Endpoints should work as they did before merging #9597.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-fy7uro?file=src%2Fpages%2Ftest.json.js

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Feb 17, 2024
@ematipico ematipico added - P5: urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority) feat: dev Related to `astro dev` CLI command (scope) regression - P4: important Violate documented behavior or significantly impacts performance (priority) and removed needs triage Issue needs to be triaged - P5: urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority) labels Feb 17, 2024
@matthewp
Copy link
Contributor

Are they broken only in development (just to understand, obviously this is still very important).

@kripod
Copy link
Author

kripod commented Feb 23, 2024

Yes, the issue only occurs in dev mode.

@ematipico ematipico self-assigned this Feb 23, 2024
@ematipico
Copy link
Member

ematipico commented Feb 23, 2024

I'll look into it

@ematipico
Copy link
Member

ematipico commented Feb 23, 2024

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 ematipico closed this as not planned Won't fix, can't repro, duplicate, stale Feb 23, 2024
@kripod
Copy link
Author

kripod commented Feb 23, 2024

@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.

@drewtownchi
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) feat: dev Related to `astro dev` CLI command (scope) regression
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants