-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(routing): return correct status code for
500.astro
and `404.ast…
…ro` (#11308) * fix(routing): return correct status code for `500.astro` and `404.astro` * changeset * fix regression * use `route` instead
- Loading branch information
Showing
14 changed files
with
100 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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 an issue where custom `404.astro` and `500.astro` were not returning the correct status code when rendered inside a rewriting cycle. |
This file contains 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 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 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 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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...fixtures/rewrite-404-invalid/package.json → .../fixtures/rewrite-custom-404/package.json
This file contains 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
10 changes: 10 additions & 0 deletions
10
packages/astro/test/fixtures/rewrite-custom-404/src/middleware.js
This file contains 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,10 @@ | ||
|
||
|
||
export const onRequest = async (context, next) => { | ||
if (context.url.pathname.startsWith("/404") || context.url.pathname.startsWith("/500")) { | ||
context.locals = { | ||
interjected: "Interjected" | ||
} | ||
} | ||
return await next(); | ||
} |
13 changes: 13 additions & 0 deletions
13
packages/astro/test/fixtures/rewrite-custom-404/src/pages/404.astro
This file contains 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,13 @@ | ||
--- | ||
const interjected = Astro.locals.interjected; | ||
--- | ||
|
||
<html> | ||
<head> | ||
<title>Custom error</title> | ||
</head> | ||
<body> | ||
<h1>Custom error</h1> | ||
<p>{interjected}</p> | ||
</body> | ||
</html> |
13 changes: 13 additions & 0 deletions
13
packages/astro/test/fixtures/rewrite-custom-404/src/pages/500.astro
This file contains 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,13 @@ | ||
--- | ||
const interjected = Astro.locals.interjected; | ||
--- | ||
|
||
<html> | ||
<head> | ||
<title>Custom error</title> | ||
</head> | ||
<body> | ||
<h1>Custom error</h1> | ||
<p>{interjected}</p> | ||
</body> | ||
</html> |
3 changes: 3 additions & 0 deletions
3
packages/astro/test/fixtures/rewrite-custom-404/src/pages/about-2.astro
This file contains 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 @@ | ||
--- | ||
return Astro.rewrite("/500") | ||
--- |
File renamed without changes.
This file contains 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.