-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Prevent static assets from being caught by catch-all routes #16047
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
58e93c9
fix: include SSR-emitted assets in manifest for Node middleware mode
matthewp 35848ed
fix build: improve changeset wording
matthewp 75317a4
revert: restore pnpm-lock.yaml and pnpm-workspace.yaml to main
matthewp cc3efea
Fix lockfile
matthewp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'astro': patch | ||
| --- | ||
|
|
||
| Fixes CSS, fonts, and other assets failing to load when using `@astrojs/node` in middleware mode with a catch-all route. Previously these assets were incorrectly matched by the catch-all instead of being served as static files. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
packages/integrations/node/test/fixtures/ssr-assets-middleware/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "name": "@test/ssr-assets-middleware", | ||
| "version": "0.0.0", | ||
| "private": true, | ||
| "dependencies": { | ||
| "@astrojs/node": "workspace:*", | ||
| "astro": "workspace:*" | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
12
packages/integrations/node/test/fixtures/ssr-assets-middleware/src/pages/[...path].astro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| --- | ||
| // Catch-all route — simulates a custom 404 handler. | ||
| // This is intentional: if SSR-emitted assets are missing from manifest.assets, | ||
| // asset requests like /_astro/*.css will match this catch-all instead of being | ||
| // served as static files. See https://github.com/withastro/astro/issues/16039 | ||
| const { path } = Astro.params; | ||
| --- | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head><title>Not Found</title></head> | ||
| <body>catch-all: {path}</body> | ||
| </html> |
7 changes: 7 additions & 0 deletions
7
packages/integrations/node/test/fixtures/ssr-assets-middleware/src/pages/index.astro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| import '../styles/main.css'; | ||
| --- | ||
| <html lang="en"> | ||
| <head><title>home</title></head> | ||
| <body><div>home</div></body> | ||
| </html> |
3 changes: 3 additions & 0 deletions
3
packages/integrations/node/test/fixtures/ssr-assets-middleware/src/styles/main.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| .container { | ||
| color: red; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the clarification! Maybe we can tweak the changeset to describe that and not suggest that those assets will definitely load (if a user doesn’t add their own static file middleware)?
Otherwise all looks good to me!