Fix callback set to NextJS data URL (#1292)

This commit is contained in:
ekzyis 2024-08-10 14:38:35 -05:00 committed by GitHub
parent ef229b378e
commit bcae5e6d2e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 1 deletions

View File

@ -142,7 +142,11 @@ export function getGetServerSideProps (
const { data: { me } } = await client.query({ query: ME })
if (authRequired && !me) {
const callback = process.env.NEXT_PUBLIC_URL + req.url
let callback = process.env.NEXT_PUBLIC_URL + req.url
// On client-side routing, the callback is a NextJS URL
// so we need to remove the NextJS stuff.
// Example: /_next/data/development/territory.json
callback = callback.replace(/\/_next\/data\/\w+\//, '/').replace(/\.json$/, '')
return {
redirect: {
destination: `/signup?callbackUrl=${encodeURIComponent(callback)}`