fix: set redirect uri for google login and prevent router push when login by google
This commit is contained in:
1
.github/CONTRIBUTING.md
vendored
1
.github/CONTRIBUTING.md
vendored
@ -87,6 +87,7 @@ Thank you for your interest in contributing to OpenCut! This document provides g
|
|||||||
# Only needed if you want to test Google login
|
# Only needed if you want to test Google login
|
||||||
GOOGLE_CLIENT_ID="your-google-client-id"
|
GOOGLE_CLIENT_ID="your-google-client-id"
|
||||||
GOOGLE_CLIENT_SECRET="your-google-client-secret"
|
GOOGLE_CLIENT_SECRET="your-google-client-secret"
|
||||||
|
GOOGLE_REDIRECT_URI="http://localhost:3000/api/auth/callback/google"
|
||||||
```
|
```
|
||||||
|
|
||||||
5. Run database migrations: `bun run db:migrate`
|
5. Run database migrations: `bun run db:migrate`
|
||||||
|
@ -10,6 +10,7 @@ BETTER_AUTH_SECRET=your-secret-key-here
|
|||||||
#Google Clients
|
#Google Clients
|
||||||
GOOGLE_CLIENT_ID=
|
GOOGLE_CLIENT_ID=
|
||||||
GOOGLE_CLIENT_SECRET=
|
GOOGLE_CLIENT_SECRET=
|
||||||
|
GOOGLE_REDIRECT_URI=http://localhost:3000/api/auth/callback/google
|
||||||
|
|
||||||
# Development Environment
|
# Development Environment
|
||||||
NODE_ENV=development
|
NODE_ENV=development
|
||||||
|
@ -52,8 +52,8 @@ function LoginForm() {
|
|||||||
try {
|
try {
|
||||||
await signIn.social({
|
await signIn.social({
|
||||||
provider: "google",
|
provider: "google",
|
||||||
|
callbackURL: "/editor",
|
||||||
});
|
});
|
||||||
router.push("/editor");
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setError("Failed to sign in with Google. Please try again.");
|
setError("Failed to sign in with Google. Please try again.");
|
||||||
setIsGoogleLoading(false);
|
setIsGoogleLoading(false);
|
||||||
|
@ -16,14 +16,15 @@ export const auth = betterAuth({
|
|||||||
emailAndPassword: {
|
emailAndPassword: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
},
|
},
|
||||||
socialProviders: {
|
socialProviders: {
|
||||||
google: {
|
google: {
|
||||||
clientId: process.env.GOOGLE_CLIENT_ID as string,
|
clientId: process.env.GOOGLE_CLIENT_ID as string,
|
||||||
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
|
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
|
||||||
|
redirectURI: process.env.GOOGLE_REDIRECT_URI as string,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
appName: "OpenCut",
|
appName: "OpenCut",
|
||||||
trustedOrigins: ["http://localhost:3000"],
|
trustedOrigins: ["http://localhost:3000"],
|
||||||
});
|
});
|
||||||
|
|
||||||
export type Auth = typeof auth;
|
export type Auth = typeof auth;
|
||||||
|
Reference in New Issue
Block a user