Add catchRedirectResponse helper

This commit is contained in:
Sam Carlton 2022-05-04 13:57:02 -05:00
parent f099a423fe
commit 2bf0572a06

17
helpers/astro/request.js Normal file
View file

@ -0,0 +1,17 @@
import { getNetlifyRedirect } from '~/helpers/config.js'
export async function catchRedirectResponse ( Astro ) {
const requestUrl = new URL( Astro.request.url )
const netlifyRedirectUrl = await getNetlifyRedirect( requestUrl.pathname )
console.log('netlifyRedirectUrl', netlifyRedirectUrl)
if ( netlifyRedirectUrl !== null ) {
return Astro.redirect( netlifyRedirectUrl.to )
}
return null
}