Hello!
I have set some secret environment variables using the Netlify UI.
In my SvelteKit app, these are imported like this:
import { SECRET_API_KEY } from '$env/static/private';
When I try to create a build, it fails with the message “Secrets scanning detected secrets in files during buildâ€.
I tried to change my imports to read the values of environment variables when the app runs, as opposed to when the app is built, like this:
import { SECRET_API_KEY } from '$env/dynamic/private';
When I did that, my app stopped working locally because it couldn’t find the environment variables anymore, and on Netlify I got an error saying ““SECRET_API_KEY†is not exported by “virtual:$env/dynamic/privateâ€â€.
What should I do to make secret environment variables work both locally and on Netlify when I use SvelteKit?
1 post - 1 participant