Access environment variables on the client

I'm not seeing anything in the docs about setting environment variables you can consume in client code. I see how to use binding for functions code. I set a variable in the back office GUI. How can I access that in my client code?
6 Replies
Cyb3r-Jak3
Cyb3r-Jak316mo ago
What do you mean by client code? During the CI process?
danboyle8637
danboyle863716mo ago
No... like lets say I have a api endpoint I don't want exposed in my git repo... so I stash it in an environment variable. I can access that locally during development but how can I expose that to my client code on the production site.
Cyb3r-Jak3
Cyb3r-Jak316mo ago
I mean if is the front end of the site then you could add it during build time with however you are building your code
danboyle8637
danboyle863716mo ago
ok. I did add an variable during build. But I don't understand how to access it in my client code. I'm using vite so typically you go import.meta.env.VITE_VARIABLE ... maybe I'm missing something obvious but how can I use the variables I set in Cloudflare in my client code?
Cyb3r-Jak3
Cyb3r-Jak316mo ago
Ah I see now. Does something like this help https://github.com/yjl9903/vite-plugin-cloudflare-functions
GitHub
GitHub - yjl9903/vite-plugin-cloudflare-functions: Make Cloudflare ...
Make Cloudflare Pages Functions works with Vite friendly - GitHub - yjl9903/vite-plugin-cloudflare-functions: Make Cloudflare Pages Functions works with Vite friendly
danboyle8637
danboyle863716mo ago
I'll take a look but I don't think this is what I'm looking for.