Possible to detect if pages is running locally or in production?

As the title says — I'm just running a normal pages project and trying to access some type of environment variable to detect if I'm running locally or am in the current deployment. Ideally I'd like to do this via an envirnment variable, but it's unclear to me if you can access these in pages without needing to be inside a CF function
3 Replies
JustinNoel
JustinNoel13mo ago
I mainly use hono now, But I'm pretty sure you use do this: context.env.ENVIRONMENT See https://developers.cloudflare.com/pages/platform/functions/bindings/#environment-variables
Bindings · Cloudflare Pages docs
A binding enables your Pages Functions to interact with resources on the Cloudflare developer platform. Use bindings to integrate your Pages Functions …
bacon
baconOP13mo ago
tried this but wasn’t working - I think it still requires a function, context wasn’t found
JustinNoel
JustinNoel13mo ago
Sorry I didn't realize what you were trying to do there. you can not access environment variables outside a function.
Want results from more Discord servers?
Add your server