Accessing env variables in server Fn
Is there a correct way to access env variables without adding VITE prefix ?
Currently I can't see them inside server functions.
6 Replies
ratty-blush•11mo ago
from vite documentation "To prevent accidentally leaking env variables to the client, only variables prefixed with VITE_ are exposed to your Vite-processed code."
equal-aquaOP•11mo ago
Correct, but we should be able to access them somehow in server functions
ratty-blush•11mo ago
hm I wouldn't think so, isnt vite building that code too?
equal-aquaOP•11mo ago
That's on Nitro in my opinion
I figured it out, seems like process.env.{var} doesnt work if .env filename is named .env.local
i changed to .env and now it's showing
fascinating-indigo•7mo ago
to bring this topic back up, is there something that keeps .env.local from working out of the box?
equal-aqua•7mo ago
not sure what that might be. vite doc says it loads .vite.env.local