Skip to content

Commit ec3de82

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

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

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[] = [

app/[lang]/stats/[login]/page.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type {ReactElement} from 'react';
22

3-
import {revalidatePath} from 'next/cache';
43
import {getDoobooStats} from '../../../../server/services/githubService';
54
import {getTranslates} from '../../../../src/localization';
65
import Container from '../Container';
@@ -26,8 +25,6 @@ export default async function Page(props: Props): Promise<ReactElement> {
2625
lang,
2726
});
2827

29-
revalidatePath('/stats', 'page');
30-
3128
return (
3229
<Container
3330
t={tStats}

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
};

server/services/githubService.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ export const getDoobooStats = async ({
608608
})
609609
.match({login: userPlugin.login});
610610

611-
if (!updatedAt || diffHours(updatedAt, today) < 3) {
611+
if (!updatedAt || diffHours(updatedAt, today) > 3) {
612612
void upsertGithubStats({
613613
plugin,
614614
user_plugin: userPlugin,
@@ -651,6 +651,12 @@ export const getDoobooStats = async ({
651651
lang,
652652
});
653653
} catch (e: any) {
654-
throw new Error(e);
654+
console.error('Error in getDoobooStats:', {
655+
login,
656+
error: e.message || e,
657+
stack: e.stack,
658+
});
659+
660+
return null;
655661
}
656662
};

0 commit comments

Comments
 (0)