Skip to content

Commit 4ace695

Browse files
committed
fix: fix some bug, remove supabase getSession warning
1 parent b5cca7e commit 4ace695

File tree

8 files changed

+25
-22
lines changed

8 files changed

+25
-22
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
"modern-screenshot": "^4.6.7",
9797
"negotiator": "^1.0.0",
9898
"next": "16.0.7",
99-
"next-intl": "^4.5.7",
99+
"next-intl": "^4.5.8",
100100
"next-themes": "^0.4.6",
101101
"next-turnstile": "^1.0.5",
102102
"nextjs-toploader": "^3.8.16",

pnpm-lock.yaml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/[lang]/(app)/auth/login/_components/LoginPasswordForm.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export function LoginPasswordForm({
3131
}), [common]);
3232

3333
const onSubmit = useCallback(async (event: React.SyntheticEvent) => {
34+
event?.preventDefault();
3435
try {
3536
setIsLoading(true);
3637
const emailForm = (event.target as HTMLFormElement).email.value;

src/app/[lang]/(app)/auth/signup/page.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { Images } from '@/config/images';
1515
import { useRandomImage } from '@/hooks/use-random-image';
1616
import { Link, useRouter } from "@/lib/i18n/navigation";
1717
import { useSearchParams } from 'next/navigation';
18-
import { useEffect, useState } from 'react';
18+
import { useCallback, useEffect, useState } from 'react';
1919
import { useSupabaseClient } from '@/context/supabase-context';
2020
import { useLocale, useTranslations } from 'next-intl';
2121
import * as z from 'zod';
@@ -151,7 +151,7 @@ export default function Signup() {
151151
// eslint-disable-next-line react-hooks/exhaustive-deps
152152
}, [usernameAvailability.isAvailable, common]);
153153

154-
const handleSubmit = async (data: SignupFormValues) => {
154+
const handleSubmit = useCallback(async (data: SignupFormValues) => {
155155
try {
156156
setIsLoading(true);
157157
if (turnstileStatus !== 'success') {
@@ -185,9 +185,9 @@ export default function Signup() {
185185
} finally {
186186
setIsLoading(false);
187187
}
188-
};
188+
}, [signup, t, common, locale, turnstileStatus]);
189189

190-
const resendOtp = async () => {
190+
const resendOtp = useCallback(async () => {
191191
try {
192192
setIsLoading(true);
193193
await loginWithOtp(form.getValues('email'), redirectTo);
@@ -207,9 +207,9 @@ export default function Signup() {
207207
} finally {
208208
setIsLoading(false);
209209
}
210-
};
210+
}, [loginWithOtp, redirectTo, form, common]);
211211

212-
const handleVerifyOtp = async (otp: string) => {
212+
const handleVerifyOtp = useCallback(async (otp: string) => {
213213
try {
214214
setIsLoading(true);
215215
const { error } = await supabase.auth.verifyOtp({
@@ -236,7 +236,7 @@ export default function Signup() {
236236
} finally {
237237
setIsLoading(false);
238238
}
239-
};
239+
}, [supabase, router, redirectTo, form, common]);
240240

241241
return (
242242
<div

src/app/[lang]/(app)/loading.tsx

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/context/supabase-context.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const SupabaseProvider = ({
1717
}) => {
1818
const locale = useLocale();
1919
const supabase = useMemo(() => {
20-
return createBrowserClient<Database>(
20+
const client = createBrowserClient<Database>(
2121
SUPABASE_URL,
2222
SUPABASE_ANON_KEY,
2323
{
@@ -28,6 +28,10 @@ export const SupabaseProvider = ({
2828
},
2929
},
3030
);
31+
32+
(client.auth as any).suppressGetSessionWarning = true;
33+
34+
return client;
3135
}, [locale]);
3236

3337
return (

src/lib/supabase/middleware.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const createMiddlewareClient = ({
1010
request: NextRequest;
1111
response: NextResponse;
1212
}) => {
13-
return createServerClient<Database>(
13+
const client = createServerClient<Database>(
1414
SUPABASE_URL,
1515
SUPABASE_ANON_KEY,
1616
{
@@ -27,4 +27,8 @@ export const createMiddlewareClient = ({
2727
},
2828
}
2929
);
30+
31+
(client.auth as any).suppressGetSessionWarning = true;
32+
33+
return client;
3034
};

src/lib/supabase/server.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { getLocale } from 'next-intl/server';
99
export const createServerClient = async () => {
1010
const cookieStore = await cookies();
1111
const locale = await getLocale();
12-
return createServerClientSupabase<Database>(
12+
const client = createServerClientSupabase<Database>(
1313
SUPABASE_URL,
1414
SUPABASE_ANON_KEY,
1515
{
@@ -36,4 +36,8 @@ export const createServerClient = async () => {
3636
}
3737
},
3838
);
39+
40+
(client.auth as any).suppressGetSessionWarning = true;
41+
42+
return client;
3943
};

0 commit comments

Comments
 (0)