Workers preview urls

Hi all, I just want to ask to confirm --- when I connect a git repo to be deployed to workers, I see it adds a comment to my PRs, but unlike Pages, this comment doesn't include a preview url (I can construct it manually but I'd like it printed on the PR like the Pages integration does). Is this the intended behavior, or is there a way I can configure it to print a preview url? Also, is it currently possible for worker project preview urls to have their own variables? My wrangler.jsonc has separate env sections with different vars blocks, but the preview branches don't seem to use them (oh, and the logs don't show any of my console.log statements, which is another thing I'm wrestling with. I'm considering going back to pages).
2 Replies
Walshy
Walshy5mo ago
You should get one, what do your build settings look like?
Matthias
MatthiasOP5mo ago
What do you mean by build settings? I was building and deploying using GitHub actions, but now I've switched to using the "connect your repository" integration. I did see some back and forth where the dashboard would keep disabling the workers.dev URL. I finally added a flag to my Wrangler file to enable it, even though the docs say the default value is true. Not sure if that was the cause of the missing preview URL in the PR comments. I'll need to create a reproduction and create a GitHub issue. It's good to know that the comment is supposed to contain a URL. What about the secrets? I'm seeing that my preview URLs are not using the secrets defined in the env.preview section of my Wrangler config. And I am passing --env preview in my deploy command for preview builds, configured in the dashboard. Can you answer about whether cloudflare currently supports giving worker preview URLs different env variables like different secrets? About secrets, I saw an older message where you said that env vars weren't implemented yet for worker previews, but they were planned in the future). That makes sense. Is the current workaround to create two separate worker projects? Or to manually deploy two envs from the same Wrangler file? That would require you to own the GitHub actions that do the deploy, and NOT use the "connect a repo" integration in the cloudflare dashboard? Does that match your understanding @Walshy ?

Did you find this page helpful?