0
Fork 0
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:
Tony Sullivan 2022-04-20 17:23:15 +02:00
parent 63209ac803
commit 4854a3f612

View file

@ -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,
},