Skip to content

Commit

Permalink
refactor: preserve prev link after sign in
Browse files Browse the repository at this point in the history
  • Loading branch information
uigywnkiub committed Dec 26, 2024
1 parent 91cb5b7 commit d058e91
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/ui/sign-in/sign-in.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
APP_TITLE,
DEFAULT_ICON_SIZE,
} from '@/config/constants/main'
import { ROUTE } from '@/config/constants/routes'

import {
TAuthProvider,
Expand Down Expand Up @@ -69,7 +68,8 @@ function SignIn() {
setIsLoading((prev) => ({ ...prev, [provider]: true }))
try {
await signIn(provider, {
callbackUrl: ROUTE.HOME,
// If no callbackUrl is provided, the user will be redirected to the previous page.
// callbackUrl: ROUTE.HOME,
})
} catch (err) {
if (err instanceof AuthError) {
Expand Down
2 changes: 1 addition & 1 deletion middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default auth((req: NextRequest & { auth: TSession }) => {
if (req.nextUrl.pathname === ROUTE.SIGNIN) {
url.pathname = ROUTE.HOME

return NextResponse.rewrite(url)
return NextResponse.redirect(url)
}

return NextResponse.next()
Expand Down

0 comments on commit d058e91

Please sign in to comment.