Dashboard environment variables not available on process.env at build time
I'm trying to deploy a tincms project to cloudflare pages. I've added these env vars in the dashboard for the project. The build-time config for tina tries to read them off process.env:
But they're undefined, breaking the build. What am I missing?
4 Replies
I am having the same problem!
I gave up unfortunately, but will still need to figure this out ðŸ«
also having this issue
https://discord.com/channels/595317990191398933/1109670750627057725/1109670750627057725
I know that this isn't the most desired function, but at the very entrance of your application, can you console.log the process object? and can you console.log the process.env object?
I was able to access the process.env on my front-end application using console.logs, and I was able to find my environment variables.
Cloudflare Pages has 2 "environments" Production & Preview; You should define these environment variables for both so if you are testing on the "dev" environment you will still be able to access these. Workers & Pages > YOUR_PAGE > Settings > Choose Environment: > Select Production OR Preview.
I was having an issue with my changes to my pages being cached, and when I would push up the changes I realized that my changes were not live (it was still returning the cached previous version). So for a while I thought I couldn't access my process.env because I wasn't getting console.logs.
Additionally I would update the keys and cloudflare would have a problem deploying the new keys, so I had to push updates a few times.
Console.logs shouldn't remain in the application of course, and any environment variables used in front-end applications will be exposed to your users. Using devtools users will be able to retrieve the tokens and keys to api's.