Skip to content

Commit

Permalink
Login redirection fix (#1242)
Browse files Browse the repository at this point in the history
Fix a problem where Next.js dynamic segment names would end up in redirected urls
  • Loading branch information
nygrenh committed Sep 21, 2023
1 parent e8524f5 commit ca74f4f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions frontend/lib/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ export const signIn = async (
}

try {
const { href } = JSON.parse(rawRedirectLocation)
const { url } = JSON.parse(rawRedirectLocation)

if (redirect) {
setTimeout(() => {
if (href) {
Router.push(href, undefined, { shallow, locale })
if (url) {
Router.push(url, undefined, { shallow, locale })
} else {
Router.back()
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/lib/redirect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function redirect({
nookies.set(
context,
"redirect-back",
JSON.stringify({ as: context.asPath, href: context.pathname }),
JSON.stringify({ url: context.asPath }),
{
maxAge: 20 * 60,
path: "/",
Expand Down

0 comments on commit ca74f4f

Please sign in to comment.