| 21 Dec 2023 |
peter-lustig | Okayyy Lily Foster, so this does not work | 16:16:47 |
peter-lustig | now in production the variables are also empty strings apparently | 16:16:59 |
Lily Foster | i was worried about that | 16:17:29 |
Lily Foster | let me dive more into the svelte docs | 16:17:38 |
Lily Foster | because you should be pulling these values at runtime rather than build time, and ideally not even require them to be set at all during build time. but idk svelte | 16:18:00 |
Lily Foster | * because you should be pulling these values at runtime rather than build time, and ideally not even require them to be set at all during build time. but idk very much about svelte | 16:18:05 |
Lily Foster |
by default from a module called _env.js — this can be configured with config.kit.env.publicModule
do you know what this part of the doc you mentioned means?
| 16:19:14 |
Lily Foster | is that how env vars should be passed in at runtime? | 16:19:22 |
peter-lustig | that line confused me too | 16:19:38 |
Lily Foster | wait, i just realized, does this mean you are importing these vars into client-side code, if it is attempting to pre-render it? | 16:20:24 |
Lily Foster | because uh 👀 | 16:20:35 |
peter-lustig | the prerendering stuff is so weird | 16:21:13 |
peter-lustig | like all of it confuses me | 16:21:16 |
peter-lustig | i had everything working with dynamic env variables and now nothing of that works anymore | 16:21:28 |
Lily Foster |
Note that all environment variables referenced in your code should be declared (for example in an .env file), even if they don't have a value until the app is deployed
hmmmmmm (from https://kit.svelte.dev/docs/modules#$env-static-private)
| 16:21:34 |
peter-lustig | In reply to @lily:lily.flowers
Note that all environment variables referenced in your code should be declared (for example in an .env file), even if they don't have a value until the app is deployed
hmmmmmm (from https://kit.svelte.dev/docs/modules#$env-static-private)
yep i saw that | 16:21:59 |
Lily Foster | In reply to @peter-lustig:matrix.org i had everything working with dynamic env variables and now nothing of that works anymore well i'm worried it's trying to include these vars in client-side generated code. which handing over secrets to the client feels ,,, problematic. would you mind sharing more of the code to help me understand? | 16:22:04 |
peter-lustig | In reply to @lily:lily.flowers well i'm worried it's trying to include these vars in client-side generated code. which handing over secrets to the client feels ,,, problematic. would you mind sharing more of the code to help me understand? import { github, google } from '@lucia-auth/oauth/providers';
import {
GITHUB_CLIENT_ID,
GITHUB_CLIENT_SECRET,
GOOGLE_CLIENT_ID,
GOOGLE_CLIENT_SECRET
} from '$env/static/private';
export const pool = new postgres.Pool({
host: '/run/postgresql',
user: 'postgres',
database: 'app'
});
export const auth = lucia({
env: dev ? 'DEV' : 'PROD',
middleware: sveltekit(),
adapter: pg(pool, {
user: 'auth_user',
key: 'user_key',
session: 'user_session'
}),
getUserAttributes: (data) => {
return {
username: data.username,
authProvider: data.auth_provider
};
}
});
export const githubAuth = github(auth, {
clientId: GITHUB_CLIENT_ID,
clientSecret: GITHUB_CLIENT_SECRET
});
| 16:23:14 |
peter-lustig | with $env/dynamic/priavate everything just worked | 16:23:31 |
peter-lustig | but in sveltekit 2.0 it does not work anymore | 16:23:36 |
Lily Foster | well apparently prior to 2.0, there was no strong distinction between those types of vars apparently | 16:24:13 |
Lily Foster | * well apparently prior to 2.0, there was no strong distinction between those types of vars | 16:24:16 |
Lily Foster | i'm gonna look up more about how lucia-auth works real quick | 16:24:39 |
Lily Foster | oh apparently lucia-auth is now just under lucia for v2 | 16:24:58 |
Lily Foster | * oh apparently lucia-auth is now just under lucia for v2 | 16:25:05 |
Lily Foster | oh but other packages are the same. ignore me. i can't read | 16:25:15 |
Lily Foster | (reading https://lucia-auth.com/migrate/v2/ rn) | 16:25:19 |
Lily Foster | well that file looks correct according to https://lucia-auth.com/guidebook/github-oauth/sveltekit/#initialize-the-oauth-integration | 16:26:43 |
Lily Foster | where and how are you using githubAuth? | 16:26:48 |
peter-lustig | this has nothing to do with lucia auth, it is just the static stuff | 16:27:24 |