persistent URL to access the latest non-production build
when i push to my
main branch, my worker runs the production build, and mywebsite.com starts serving the latest commit
how can i access my latest development preview link (which is only generated when a dev pushes a commit to a PR, e.g., https://COMMIT-HASH.WORKER-NAME.CLOUDFLARE-USERNAME.workers.dev)13 Replies
@texan thread
Thank you! đ yeah letâs recap. So you currently deploy to your workers.dev on merge to main, yeah?
Do you also want main to auto deploy? Or just give you a âpreviewâ?
yes, when i push to
main I want 2 things:
1. mywebsite.com to serve the latest build (this is already working as expected)
2. some-persistent-url.com (can be autogenerated workers.dev url) to serve the latest build just like step 1Ah ok, yeah so you would create another environment through wrangler, and do a deploy to that as well. Build + deploy production + deploy other worker
Cloudflare Docs
Environments
Use environments to create different configurations for the same Worker application.
Just extend your mainâs deploy command to also have â&& npx wrangler deploy -e someotherenvâ
That way you have a second worker with a totally separate set of bindings
Not sure why youâd want that though? So maybe Iâm misunderstanding
Not sure why youâd want that though? So maybe Iâm misunderstandingi need internal teams to access the latest build (same one as in production), but with development values
Yup, then youâll want a separate worker via wrangler environments
But I would say maybe you ACTUALLY want to test before you push to main đ
yep, testers already use the preview links
but some devs and PMs need the latest link with dev env values, so they can explore the latest version using the dev db
Right, but you could use the same strategy to upload a version to your development worker before merging đ
However you decide! Totally possible đ feel free to create a workers help thread if you get stuck!
Right, but you could use the same strategy to upload a version to your development worker before merging đbut wouldn't different commits in different PRs override the worker?
Youâd do âversion upload -e stagingâ and your preview link will be a non deployed version connected to dev worker
If you need a stable name, yeah, it would conflict with each pr
But you can get around this too with a custom npm script to do the alias yourself based on the branch (in that case your deploy command for non production would be npm run deploy, and youâd handle the wrangler commands yourself)
makes sense, i will experiment now. Thank you Will for your help