Example of setting up staging and production environments

I’m trying to set up separate staging and production environments for my Pages app, does anyone have examples of how they did it? I’m not sure whether I should contain everything in one “app” in the CF dashboard with a dedicated staging branch, or have a totally separate “app” for staging. It seems like 1 app would be easier for maintenance, however the env settings for the preview branches and staging will have to be exactly the same. Alternatively 2 apps would make it easier to manually promote certain versions to staging, and also let me test preview branches connected to either the staging and production databases as needed.
1 Reply
Martijn
Martijn7mo ago
I do mine in one project: the latest (preview-) build for any non-main branch is always at <branch>.<project>.pages.dev and you can set up specific environment variables as well as bindings (like KV or R2) for those preview builds in the settings of your project. You can set up those different environment variables in your pages project > Settings > Environment variables (notice "preview" at the bottom, those will be used for all preview builds aka builds for non-main branches) Same goes for bindings: go to Settings > Functions and when you scroll down to the different bindings, you see a tab for Production and Preview separately under each type of binding
Want results from more Discord servers?
Add your server