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
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-variablesBindings · 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 …
tried this but wasn’t working - I think it still requires a function, context wasn’t found
Sorry I didn't realize what you were trying to do there. you can not access environment variables outside a function.