-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
fix: allow dynamic parameters in .html.astro routes #15944
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
Princesseuh
merged 6 commits into
withastro:main
from
fkatsuhiro:fix/ssr-cannot-handle-slug-html-astro
Mar 18, 2026
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
95c60cd
fix: allow dynamic parameters in .html.astro routes
fkatsuhiro 9c1f249
feat: changeset
fkatsuhiro e4948f5
test: move ssr .html test from e2e to unit
fkatsuhiro 1ffb908
chore: clenaup
Princesseuh 7072e54
Merge branch 'main' into fix/ssr-cannot-handle-slug-html-astro
Princesseuh a24ec0c
fix: skip normalization
Princesseuh 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': major | ||
| --- | ||
|
|
||
| allow dynamic parameters in .html.astro routes |
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
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
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 { defineConfig } from 'astro/config'; | ||
| import node from '@astrojs/node'; | ||
|
|
||
| export default defineConfig({ | ||
| output: 'server', | ||
| adapter: node({ mode: 'standalone' }), | ||
| }); |
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": "ssr-html-route", | ||
| "type": "module", | ||
| "private": true, | ||
| "dependencies": { | ||
| "astro": "workspace:*", | ||
| "@astrojs/node": "workspace:*" | ||
| } | ||
| } |
9 changes: 9 additions & 0 deletions
9
packages/astro/test/fixtures/ssr-html-route/src/pages/[slug].html.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,9 @@ | ||
| --- | ||
| const { slug } = Astro.params; | ||
| --- | ||
| <html> | ||
| <head><title>Dynamic HTML Route</title></head> | ||
| <body> | ||
| <div>Slug: {slug}</div> | ||
| </body> | ||
| </html> |
3 changes: 3 additions & 0 deletions
3
packages/astro/test/fixtures/ssr-html-route/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,3 @@ | ||
| --- | ||
| --- | ||
| <div>Home</div> |
9 changes: 9 additions & 0 deletions
9
packages/astro/test/fixtures/ssr-html-route/src/pages/standard.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,9 @@ | ||
| --- | ||
| // URL: /standard.html | ||
| --- | ||
| <html> | ||
| <head><title>Standard Route</title></head> | ||
| <body> | ||
| <div>standard</div> | ||
| </body> | ||
| </html> |
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,40 @@ | ||
| import assert from 'node:assert/strict'; | ||
| import { before, after, describe, it } from 'node:test'; | ||
| import { loadFixture } from './test-utils.js'; | ||
|
|
||
| describe('SSR: [slug].html.astro routing', () => { | ||
| let fixture; | ||
| let devServer; | ||
|
|
||
| before(async () => { | ||
| fixture = await loadFixture({ | ||
| root: './fixtures/ssr-html-route/', | ||
| }); | ||
| devServer = await fixture.startDevServer(); | ||
| }); | ||
|
|
||
| after(async () => { | ||
| if (devServer) await devServer.stop(); | ||
| }); | ||
|
|
||
| it('extracts params correctly from [slug].html.astro', async () => { | ||
| const response = await fixture.fetch('/dummy.html'); | ||
| assert.equal(response.status, 200); | ||
| const html = await response.text(); | ||
| assert.match(html, /Slug: dummy/); | ||
| }); | ||
|
|
||
| it('should still work for standard [slug].astro by stripping .html from URL', async () => { | ||
| const response = await fixture.fetch('/standard.html'); | ||
| assert.equal(response.status, 200); | ||
| const html = await response.text(); | ||
| assert.match(html, /standard/); | ||
| }); | ||
|
|
||
| it('should normalize index.html to /', async () => { | ||
| const response = await fixture.fetch('/index.html'); | ||
| assert.equal(response.status, 200); | ||
| const html = await response.text(); | ||
| assert.match(html, /Home/); | ||
| }); | ||
| }); | ||
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.
Uh oh!
There was an error while loading. Please reload this page.