T
TanStack2mo ago
fair-rose

netlify deploy error

When deploying to Netlify, It fails building the app, with the message that env vars shouldn't be used in client code. How can I solve this?? Netlify logs: 11:45:38 PM: Secret env var "VITE_CONVEXURL"'s value detected: found value at line 1464 in .netlify/functions-internal/server/chunks//ssr.mjs 11:45:38 PM: found value at line 68 in .tanstack/start/build/client-dist/assets/main-BHcXIkoc.js 11:45:38 PM: found value at line 68 in dist/assets/main-BHcXIkoc.js 11:45:38 PM: ​ 11:45:38 PM: To prevent exposing secrets, the build will fail until these secret values are not found in build output or repo files. Refering to this code (I think):
const CONVEX_URL = (import.meta as any).env.VITE_CONVEX_URL!
if (!CONVEX_URL) {
console.error('missing envar CONVEX_URL')
}
const convexQueryClient = new ConvexQueryClient(CONVEX_URL)
const CONVEX_URL = (import.meta as any).env.VITE_CONVEX_URL!
if (!CONVEX_URL) {
console.error('missing envar CONVEX_URL')
}
const convexQueryClient = new ConvexQueryClient(CONVEX_URL)
5 Replies
stormy-gold
stormy-gold2mo ago
cc @Netlify (Partner)
fair-rose
fair-roseOP2mo ago
I used process.env.___, and now there's no error. Not sure why...
harsh-harlequin
harsh-harlequin2mo ago
process.env is generally for envs destined for the server import.meta.env.VITE_<name> is for client
xenial-black
xenial-black2mo ago
You can also check out "Manage false positives" here: https://docs.netlify.com/manage/security/secret-scanning/
fair-rose
fair-roseOP5w ago
Thanks, that's what I found out...

Did you find this page helpful?