mirror of
https://github.com/BradNut/boredgame
synced 2025-09-08 17:40:22 +00:00
Fixing auth cookie value to be vercel url or backup.
This commit is contained in:
parent
c01418805b
commit
e6ea744f0a
3 changed files with 12 additions and 9 deletions
|
|
@ -11,10 +11,10 @@ export default defineConfig({
|
||||||
user: process.env.DATABASE_USER,
|
user: process.env.DATABASE_USER,
|
||||||
password: process.env.DATABASE_PASSWORD,
|
password: process.env.DATABASE_PASSWORD,
|
||||||
database: process.env.DATABASE || 'boredgame',
|
database: process.env.DATABASE || 'boredgame',
|
||||||
ssl: process.env.DATABASE_HOST === 'localhost' ? false : true,
|
ssl: process.env.DATABASE_HOST !== 'localhost'
|
||||||
},
|
},
|
||||||
// Print all statements
|
// Print all statements
|
||||||
verbose: true,
|
verbose: true,
|
||||||
// Always as for confirmation
|
// Always as for confirmation
|
||||||
strict: true
|
strict: true
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import {
|
||||||
DATABASE_PASSWORD,
|
DATABASE_PASSWORD,
|
||||||
DATABASE_HOST,
|
DATABASE_HOST,
|
||||||
DATABASE_DB,
|
DATABASE_DB,
|
||||||
DATABASE_PORT,
|
DATABASE_PORT
|
||||||
} from '$env/static/private';
|
} from '$env/static/private';
|
||||||
import * as schema from '../schema';
|
import * as schema from '../schema';
|
||||||
|
|
||||||
|
|
@ -16,7 +16,7 @@ const pool = new pg.Pool({
|
||||||
host: DATABASE_HOST,
|
host: DATABASE_HOST,
|
||||||
port: Number(DATABASE_PORT).valueOf(),
|
port: Number(DATABASE_PORT).valueOf(),
|
||||||
database: DATABASE_DB,
|
database: DATABASE_DB,
|
||||||
ssl: DATABASE_HOST === 'localhost' ? false : true,
|
ssl: DATABASE_HOST !== 'localhost'
|
||||||
});
|
});
|
||||||
|
|
||||||
// user: DATABASE_USER,
|
// user: DATABASE_USER,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// lib/server/lucia.ts
|
// lib/server/lucia.ts
|
||||||
import { Lucia, TimeSpan } from 'lucia';
|
import { Lucia, TimeSpan } from 'lucia';
|
||||||
import { DrizzlePostgreSQLAdapter } from "@lucia-auth/adapter-drizzle";
|
import { DrizzlePostgreSQLAdapter } from '@lucia-auth/adapter-drizzle';
|
||||||
import db from '$lib/drizzle';
|
import db from '$lib/drizzle';
|
||||||
import { sessions, users } from '../../schema';
|
import { sessions, users } from '../../schema';
|
||||||
|
|
||||||
|
|
@ -22,7 +22,7 @@ export const lucia = new Lucia(adapter, {
|
||||||
theme: attributes.theme
|
theme: attributes.theme
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
sessionExpiresIn: new TimeSpan(30, "d"), // 30 days
|
sessionExpiresIn: new TimeSpan(30, 'd'), // 30 days
|
||||||
sessionCookie: {
|
sessionCookie: {
|
||||||
name: 'session',
|
name: 'session',
|
||||||
expires: false, // session cookies have very long lifespan (2 years)
|
expires: false, // session cookies have very long lifespan (2 years)
|
||||||
|
|
@ -30,12 +30,15 @@ export const lucia = new Lucia(adapter, {
|
||||||
// set to `true` when using HTTPS
|
// set to `true` when using HTTPS
|
||||||
secure: process.env.NODE_ENV === 'production',
|
secure: process.env.NODE_ENV === 'production',
|
||||||
sameSite: 'strict',
|
sameSite: 'strict',
|
||||||
domain: process.env.NODE_ENV === 'production' ? 'boredgame.vercel.app' : 'localhost',
|
domain:
|
||||||
|
process.env.NODE_ENV === 'production'
|
||||||
|
? process.env.VERCEL_URL ?? 'boredgame.vercel.app'
|
||||||
|
: 'localhost'
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
declare module "lucia" {
|
declare module 'lucia' {
|
||||||
interface Register {
|
interface Register {
|
||||||
Lucia: typeof lucia;
|
Lucia: typeof lucia;
|
||||||
DatabaseUserAttributes: DatabaseUserAttributes;
|
DatabaseUserAttributes: DatabaseUserAttributes;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue