Skip to content

Commit 6cf8ff7

Browse files
add oAuthProxy
1 parent 5fd22ea commit 6cf8ff7

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/components/Auth.astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const session = await auth.api.getSession({
3232
document.querySelector("#login")?.addEventListener("click", async () => {
3333
await signIn.social({
3434
provider: "github",
35+
callbackURL: "/",
3536
});
3637
});
3738
document.querySelector("#logout")?.addEventListener("click", async () => {

src/lib/auth.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { betterAuth } from 'better-auth';
2-
import { admin } from 'better-auth/plugins';
2+
import { admin, oAuthProxy } from 'better-auth/plugins';
33
import { D1Dialect } from 'kysely-d1';
44

55
export const auth = (url: string, env: Env) => {
@@ -13,11 +13,18 @@ export const auth = (url: string, env: Env) => {
1313
rateLimit: {
1414
enabled: true,
1515
},
16-
plugins: [admin()],
16+
plugins: [
17+
oAuthProxy({
18+
productionURL: 'https://astro-tips.dev',
19+
currentURL: url,
20+
}),
21+
admin(),
22+
],
1723
socialProviders: {
1824
github: {
1925
clientId: env.GITHUB_CLIENT_ID,
2026
clientSecret: env.GITHUB_CLIENT_SECRET,
27+
redirectURI: `https://astro-tips.dev/api/auth/callback/github`,
2128
},
2229
},
2330
});

0 commit comments

Comments
 (0)