Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't build when using env var as secret #50

Closed
muckelba opened this issue Jan 5, 2023 · 3 comments
Closed

Can't build when using env var as secret #50

muckelba opened this issue Jan 5, 2023 · 3 comments

Comments

@muckelba
Copy link

muckelba commented Jan 5, 2023

Hi,

i'm trying to build my svelte app with the node adapter, but it errors, because i want to set the session secret via an environment variable when launching the server:

src/hooks.server.js:

import { handleSession } from 'svelte-kit-cookie-session';
import { env } from '$env/dynamic/private';

const sessionSecret = env.VITE_SESSION_SECRET

export const handle = handleSession({
	secret: sessionSecret
});

Error when running npm run build:

Error: Please provide at least one secret
    at normalizeConfig (file:///redacted/node_modules/svelte-kit-cookie-session/utils.js:12:15)
    at new CookieSession (file:///redacted/node_modules/svelte-kit-cookie-session/core.js:14:24)
    at Object.handle (file:///redacted/node_modules/svelte-kit-cookie-session/handle.js:4:25)
    at respond (file:///redacted/.svelte-kit/output/server/index.js:2205:42)
    at async visit (file:///redacted/node_modules/@sveltejs/kit/src/core/prerender/prerender.js:190:20)

Is it possible to fix that or do i have to think about a different way where i dont have to build the app with a hardcoded sessionsecret?

@muckelba
Copy link
Author

muckelba commented Jan 5, 2023

Okay, nevermind it's working. Forgot to exclude this file from prerendering.

@muckelba muckelba closed this as completed Jan 5, 2023
@muckelba
Copy link
Author

muckelba commented Jan 5, 2023

I'm sorry, the issue is not fixed. I had an .env in my project while building the app, that's why it was working. But after i renamed it, i was'nt able to build again.

@muckelba muckelba reopened this Jan 5, 2023
@pixelmund
Copy link
Owner

I can't reproduce your issue, if you provide a minimal reproduction i'll reopen it!

@pixelmund pixelmund closed this as not planned Won't fix, can't repro, duplicate, stale Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants