-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
automatically replace $env variables with process.env in edge functions #7556
Comments
Basically, the In the meantime, if you have the ability to use Removing the 1.0 milestone since it's a platform issue rather than a SvelteKit one. |
Ok, thanks for the update. In my case, this was okay (with Supabase): import { PUBLIC_SUPABASE_ANON_KEY, PUBLIC_SUPABASE_URL } from '$env/static/public'; J Good to know Vercel is working on getting everything working the same across environments. |
Can confirm this is how I set up my import { createClient } from '@supabase/auth-helpers-sveltekit';
// import { env } from '$env/dynamic/public';
import { PUBLIC_SUPABASE_ANON_KEY, PUBLIC_SUPABASE_URL } from '$env/static/public';
//export const supabase = createClient(env.PUBLIC_SUPABASE_URL, env.PUBLIC_SUPABASE_ANON_KEY);
export const supabase = createClient(PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY); |
I also ran into this issue recently, however even when following the documentation and setting From the sveltekit docs: From the vercel docs: My However this simple repro shows that even that is non-functional. On vercel before building the project I have specified the environment variables like this: But in the deployment: https://sveltekit-env-vars-repro.vercel.app/ only the I noticed that both of the documentations mention Am I potentially missing something here or does Either way if the dynamic option really doesn't work, it's going to be difficult for us to maintain both a Vercel and self-hosted docker image, where in the latter case consumer should supply their own keys. Edit: I just noticed that just plainly using |
As of I updated the repro repo with these version bumps and was able to observe the expected environment variables. I did remove the Vercel deployment so I don't expose my other vercel variables. This can be closed now because #9942 fixes the issue. Thanks for resolving the issue! |
Describe the problem
Edge functions in Vercel do not work as expected. You have to specify the variable EXACTLY in
process.env
for it to work, while $env seem to get translated automatically in regular lambdas.It would be nice if all $env variables were replaced with
process.env
so that I would not have to configure it manually with something like:Describe the proposed solution
The vercel adapter does this if the
edge: true
is set.Alternatives considered
My workaround code above.
Importance
would make my life easier
Additional Information
Obviously this would not be necessary if SvelteKit handled this internally, or if Vercel Edge functions handled env variables the same way as regular functions.
The text was updated successfully, but these errors were encountered: