mirror of
https://github.com/withastro/astro.git
synced 2025-03-24 23:21:57 -05:00
fix(redirects): correctly compute the status code in redirects (#9657)
This commit is contained in:
parent
a1b56ee1fa
commit
a4f90d95ff
3 changed files with 14 additions and 3 deletions
5
.changeset/honest-seas-raise.md
Normal file
5
.changeset/honest-seas-raise.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"astro": patch
|
||||
---
|
||||
|
||||
Fixes a bug where the custom status code wasn't correctly computed in the dev server
|
|
@ -36,8 +36,8 @@ export function redirectRouteGenerate(redirectRoute: RouteData, data: Params): s
|
|||
|
||||
export function redirectRouteStatus(redirectRoute: RouteData, method = 'GET'): ValidRedirectStatus {
|
||||
const routeData = redirectRoute.redirectRoute;
|
||||
if (typeof routeData?.redirect === 'object') {
|
||||
return routeData.redirect.status;
|
||||
if (routeData && typeof redirectRoute.redirect === 'object') {
|
||||
return redirectRoute.redirect.status;
|
||||
} else if (method !== 'GET') {
|
||||
return 308;
|
||||
}
|
||||
|
|
|
@ -477,7 +477,13 @@ export function createRouteManifest(
|
|||
pathname: pathname || void 0,
|
||||
prerender: false,
|
||||
redirect: to,
|
||||
redirectRoute: routes.find((r) => r.route === to),
|
||||
redirectRoute: routes.find((r) => {
|
||||
if (typeof to === 'object') {
|
||||
return r.route === to.destination;
|
||||
} else {
|
||||
return r.route === to;
|
||||
}
|
||||
}),
|
||||
fallbackRoutes: [],
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue