diff --git a/package.json b/package.json index 7a8aa1f..2e5361a 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "concurrently": "^9.1.2", "convex": "^1.24.8", "convex-svelte": "^0.0.11", + "dotenv": "^16.5.0", "eslint": "^9.18.0", "eslint-config-prettier": "^10.0.1", "eslint-plugin-svelte": "^3.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index adf8081..a2b5c70 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -60,6 +60,9 @@ importers: convex-svelte: specifier: ^0.0.11 version: 0.0.11(convex@1.24.8)(svelte@5.34.1) + dotenv: + specifier: ^16.5.0 + version: 16.5.0 eslint: specifier: ^9.18.0 version: 9.28.0(jiti@2.4.2) @@ -1247,6 +1250,10 @@ packages: dom-accessibility-api@0.6.3: resolution: {integrity: sha512-7ZgogeTnjuHbo+ct10G9Ffp0mif17idi0IyWNVA/wcwcm7NPOD/WEHVP3n7n3MhXqxoIYm8d6MuZohYWIZ4T3w==} + dotenv@16.5.0: + resolution: {integrity: sha512-m/C+AwOAr9/W1UOIZUo232ejMNnJAJtYQjUbHoNTBNTJSvqzzDh7vnrei3o3r3m9blf6ZoDkvcw0VmozNRFJxg==} + engines: {node: '>=12'} + emoji-regex@8.0.0: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} @@ -3337,6 +3344,8 @@ snapshots: dom-accessibility-api@0.6.3: {} + dotenv@16.5.0: {} + emoji-regex@8.0.0: {} enhanced-resolve@5.18.1: diff --git a/src/lib/auth.ts b/src/lib/auth.ts index 22ccd0f..69f1794 100644 --- a/src/lib/auth.ts +++ b/src/lib/auth.ts @@ -1,17 +1,18 @@ import { betterAuth } from 'better-auth'; import { convexAdapter } from '@better-auth-kit/convex'; import { ConvexHttpClient } from 'convex/browser'; +import 'dotenv/config'; -const convexClient = new ConvexHttpClient(process.env.CONVEX_SITE_URL!); +const convexClient = new ConvexHttpClient(process.env.PUBLIC_CONVEX_URL!); export const auth = betterAuth({ secret: process.env.BETTER_AUTH_SECRET!, database: convexAdapter(convexClient), socialProviders: { - // github: { - // clientId: process.env.GITHUB_CLIENT_ID!, - // clientSecret: process.env.GITHUB_CLIENT_SECRET! - // } + github: { + clientId: process.env.GITHUB_CLIENT_ID!, + clientSecret: process.env.GITHUB_CLIENT_SECRET! + } }, plugins: [] }); diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 02f2a67..f1da6cd 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -3,10 +3,15 @@ import { authClient } from '$lib/backend/auth/client'; async function signInGithub() { - await authClient.signIn.social({ - provider: 'github', - callbackURL: '/chat' - }); + try { + console.log('signInGithub'); + const data = await authClient.signIn.social({ + provider: 'github' + }); + console.log('signInGithub data', data); + } catch (e) { + console.log('signInGithub error', e); + } }