diff --git a/pages/login.js b/pages/login.js index b167aa07..13eea733 100644 --- a/pages/login.js +++ b/pages/login.js @@ -7,7 +7,13 @@ import { isExternal } from '../lib/url' export async function getServerSideProps ({ req, res, query: { callbackUrl, error = null } }) { const session = await getSession({ req }) - const external = isExternal(decodeURIComponent(callbackUrl)) + // assume external by default so we will use fallback callback + let external = true; + try { + external = isExternal(decodeURIComponent(callbackUrl)) + } catch (err) { + console.error("error decoding callback:", callbackUrl, err) + } if (external) { // This is a hotfix for open redirects. See https://github.com/stackernews/stacker.news/issues/264 callbackUrl = '/' diff --git a/pages/signup.js b/pages/signup.js index 1a2b7389..697837f3 100644 --- a/pages/signup.js +++ b/pages/signup.js @@ -7,7 +7,13 @@ import { isExternal } from '../lib/url' export async function getServerSideProps ({ req, res, query: { callbackUrl, error = null } }) { const session = await getSession({ req }) - const external = isExternal(decodeURIComponent(callbackUrl)) + // assume external by default so we will use fallback callback + let external = true; + try { + external = isExternal(decodeURIComponent(callbackUrl)) + } catch (err) { + console.error("error decoding callback:", callbackUrl, err) + } if (external) { // This is a hotfix for open redirects. See https://github.com/stackernews/stacker.news/issues/264 callbackUrl = '/'