Skip to content

Guidance on environment variables #147

Closed Answered by victoralvelais
victoralvelais asked this question in Q&A
Discussion options

You must be logged in to vote

I figured it out. Vite uses a different syntax for the environment variables, import.meta.env instead of process.env. I tried that before and it didn’t work, but the issue is that it requires the VITE_ prefix to expose these variables to the client. I didn’t know that included the loader functions since there was no issues in Remix dev, but I ran into this double gotcha.

I also want to continue using process.env instead of the other syntax, so I added it back here, filtering for the VITE_ prefix:

import { vitePlugin as remix } from "@remix-run/dev";
import tsconfigPaths from "vite-tsconfig-paths";
import { defineConfig, loadEnv } from 'vite';
import { netlifyPlugin } from "@netlify/remix-…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by victoralvelais
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant