0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-02-24 22:46:02 -05:00

fix: lost the leading slash when redirecting

This commit is contained in:
Tony Sullivan 2022-04-20 17:51:49 +02:00
parent 4854a3f612
commit a64f4fec32

View file

@ -115,9 +115,11 @@ async function handle404Response(
const redirectTo =
req.method === 'GET'
&& config.base && config.base !== './'
&& pathname.replace(config.base, '');
&& pathname.startsWith(config.base)
&& pathname.replace(config.base, '/');
if (redirectTo && redirectTo !== '/') {
console.log('redirecting', pathname, redirectTo);
const response = new Response(null, {
status: 302,
headers: {