Skip to content

Is there a better way to use environment variables with Cloudflare Pages? #1288

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

You must be logged in to vote

Part of the reason I went down the route above is because the server was crashing when trying to access process.env. Is this a bug, or is process undefined because we're in a 'serverless' environment?

It’s undefined because process is a Node thing and Cloudflare Workers doesn’t use Node, they have a different runtime, in other Serverless platforms you could use process.

Why doesn't {process.env.NODE_ENV === 'development' ? : null} (from root.tsx in the Remix template) cause any issues?

This is because that specific line is being replaced with the value at build, so when running Remix in dev it will be replaced with the string development and when you build for production it will be re…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@simonsinclair
Comment options

Answer selected by simonsinclair
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants