mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Add catchRedirectResponse helper
This commit is contained in:
parent
f099a423fe
commit
2bf0572a06
1 changed files with 17 additions and 0 deletions
17
helpers/astro/request.js
Normal file
17
helpers/astro/request.js
Normal 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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue