!NhAsaYbbgmzHtXTPQJ:funklause.de

Nix NodeJS

201 Members
60 Servers

Load older messages


SenderMessageTime
21 Dec 2023
@peter-lustig:matrix.orgpeter-lustigI will try now xd16:10:37
@lily:lily.flowersLily Fosteri do hope it is that simple!16:11:21
@lily:lily.flowersLily Fosternot sure how many variables you have in the file, but you will likely need to define all of them16:11:46
@lily:lily.flowersLily Fosteri wonder why svelte doesn't have a way to say "this won't be needed at build time, just put a blank value in"16:12:02
@peter-lustig:matrix.orgpeter-lustigjust four16:12:08
@peter-lustig:matrix.orgpeter-lustig
In reply to @lily:lily.flowers
i wonder why svelte doesn't have a way to say "this won't be needed at build time, just put a blank value in"
idk maybe they do but not many people use sveltekit compared to react for example so finding stuff out is usually difficult
16:12:34
@lily:lily.flowersLily Foster
In reply to @peter-lustig:matrix.org
idk maybe they do but not many people use sveltekit compared to react for example so finding stuff out is usually difficult
that's pretty fair tbh, i could totally see that
16:12:53
@peter-lustig:matrix.orgpeter-lustigok so now the stuff builds16:13:05
@peter-lustig:matrix.orgpeter-lustigi guess it would just work now, let me test this in production16:13:13
@peter-lustig:matrix.orgpeter-lustig
In reply to @lily:lily.flowers
there is no npm/nix difference here. the difference is you are baking in variables that you are making available in your local env but not in your nix build env
ah i thought nix could read my local .env file
16:13:49
@peter-lustig:matrix.orgpeter-lustigwith some magic xd16:15:58
@peter-lustig:matrix.orgpeter-lustig Okayyy Lily Foster, so this does not work 16:16:47
@peter-lustig:matrix.orgpeter-lustignow in production the variables are also empty strings apparently16:16:59
@lily:lily.flowersLily Fosteri was worried about that16:17:29
@lily:lily.flowersLily Fosterlet me dive more into the svelte docs16:17:38
@lily:lily.flowersLily Fosterbecause 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 svelte16:18:00
@lily:lily.flowersLily 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 svelte16:18:05
@lily:lily.flowersLily 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:lily.flowersLily Fosteris that how env vars should be passed in at runtime?16:19:22
@peter-lustig:matrix.orgpeter-lustigthat line confused me too16:19:38
@lily:lily.flowersLily Fosterwait, 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:lily.flowersLily Fosterbecause uh 👀16:20:35
@peter-lustig:matrix.orgpeter-lustigthe prerendering stuff is so weird16:21:13
@peter-lustig:matrix.orgpeter-lustiglike all of it confuses me16:21:16
@peter-lustig:matrix.orgpeter-lustigi had everything working with dynamic env variables and now nothing of that works anymore16:21:28
@lily:lily.flowersLily 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:matrix.orgpeter-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:lily.flowersLily 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:matrix.orgpeter-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:matrix.orgpeter-lustigwith $env/dynamic/priavate everything just worked16:23:31

Show newer messages


Back to Room ListRoom Version: 6