fix
All checks were successful
Build and Push Container Image / build-and-push (push) Successful in 5m6s
All checks were successful
Build and Push Container Image / build-and-push (push) Successful in 5m6s
This commit is contained in:
@@ -5,23 +5,35 @@ import { env } from '$env/dynamic/private';
|
||||
import { getRequestEvent } from '$app/server';
|
||||
import { db } from '$lib/server/db';
|
||||
|
||||
if (!env.ORIGIN) throw new Error('ORIGIN is not set');
|
||||
if (!env.BETTER_AUTH_SECRET) throw new Error('BETTER_AUTH_SECRET is not set');
|
||||
if (!env.GITHUB_CLIENT_ID) throw new Error('GITHUB_CLIENT_ID is not set');
|
||||
if (!env.GITHUB_CLIENT_SECRET) throw new Error('GITHUB_CLIENT_SECRET is not set');
|
||||
function createAuth() {
|
||||
const origin = env.ORIGIN;
|
||||
if (!origin) throw new Error('ORIGIN is not set');
|
||||
const secret = env.BETTER_AUTH_SECRET;
|
||||
if (!secret) throw new Error('BETTER_AUTH_SECRET is not set');
|
||||
const clientId = env.GITHUB_CLIENT_ID;
|
||||
if (!clientId) throw new Error('GITHUB_CLIENT_ID is not set');
|
||||
const clientSecret = env.GITHUB_CLIENT_SECRET;
|
||||
if (!clientSecret) throw new Error('GITHUB_CLIENT_SECRET is not set');
|
||||
|
||||
export const auth = betterAuth({
|
||||
baseURL: env.ORIGIN,
|
||||
secret: env.BETTER_AUTH_SECRET,
|
||||
database: drizzleAdapter(db, { provider: 'pg' }),
|
||||
emailAndPassword: { enabled: true },
|
||||
socialProviders: {
|
||||
github: {
|
||||
clientId: env.GITHUB_CLIENT_ID,
|
||||
clientSecret: env.GITHUB_CLIENT_SECRET
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
sveltekitCookies(getRequestEvent) // make sure this is the last plugin in the array
|
||||
]
|
||||
return betterAuth({
|
||||
baseURL: origin,
|
||||
secret,
|
||||
database: drizzleAdapter(db, { provider: 'pg' }),
|
||||
emailAndPassword: { enabled: true },
|
||||
socialProviders: {
|
||||
github: { clientId, clientSecret }
|
||||
},
|
||||
plugins: [
|
||||
sveltekitCookies(getRequestEvent)
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
let _auth: ReturnType<typeof betterAuth>;
|
||||
|
||||
export const auth = new Proxy({} as ReturnType<typeof betterAuth>, {
|
||||
get(target, prop) {
|
||||
if (!_auth) _auth = createAuth();
|
||||
return Reflect.get(_auth, prop, target);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user