Skip to content

Commit 9d2ba5f

Browse files
committed
fix: proxy to handle auth
1 parent 38a9b19 commit 9d2ba5f

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

app/[lang]/sign-in/SocialButtons.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ export default function SocialButtons({
3131

3232
const normalizedRoot = process.env.NEXT_PUBLIC_ROOT_URL.replace(/\/$/, '');
3333

34-
return `${normalizedRoot}/auth/callback?next=${encodeURIComponent(pathname || '/')}`;
34+
// If we're on the sign-in page, redirect to home after successful login
35+
const nextPath = pathname?.includes('/sign-in')
36+
? pathname.replace(/\/sign-in.*$/, '') || '/'
37+
: pathname || '/';
38+
39+
return `${normalizedRoot}/auth/callback?next=${encodeURIComponent(nextPath)}`;
3540
}, [pathname]);
3641

3742
const socialButtons: SocialButton[] = [

proxy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,6 @@ export async function proxy(
7878
}
7979

8080
export const config = {
81-
// Matcher ignoring `/_next/`, `/api/` and `/assets/`
82-
matcher: ['/((?!api|assets|_next/static|_next/image|favicon.ico|public).*)'],
81+
// Matcher ignoring `/_next/`, `/api/`, `/auth/` and `/assets/`
82+
matcher: ['/((?!api|auth|assets|_next/static|_next/image|favicon.ico|public).*)'],
8383
};

0 commit comments

Comments
 (0)