mirror of
https://github.com/withastro/astro.git
synced 2025-03-31 23:31:30 -05:00
one last safety check - only redirect GET and use a 302 status
This commit is contained in:
parent
63209ac803
commit
4854a3f612
1 changed files with 4 additions and 2 deletions
|
@ -112,12 +112,14 @@ async function handle404Response(
|
|||
html = subpathNotUsedTemplate(devRoot, pathname);
|
||||
} else {
|
||||
// HACK: redirect without the base path for assets in publicDir
|
||||
const redirectTo = config.base && config.base !== './'
|
||||
const redirectTo =
|
||||
req.method === 'GET'
|
||||
&& config.base && config.base !== './'
|
||||
&& pathname.replace(config.base, '');
|
||||
|
||||
if (redirectTo && redirectTo !== '/') {
|
||||
const response = new Response(null, {
|
||||
status: 301,
|
||||
status: 302,
|
||||
headers: {
|
||||
Location: redirectTo,
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue