CF Pages Preview deploys always have different URLs

According to https://developers.cloudflare.com/pages/platform/preview-deployments :

Preview deployments allow you to preview new versions of your project without deploying it to production.

Every time you open a new pull request on your GitHub repository, Cloudflare Pages will create a unique preview URL, which will stay up-to-date as you continue to push new commits to the branch.

But every preview deployment I build gets a different, random URL. I’ve tried pushing to the same (non production) branch, an also opening a pull request from that branch to the production branch. And then adding a commit to the develop branch while the pull request is open. The pull request shows multiple preview deployments, but with a different URL for each deployment.

Ideally I’d like to associate a branch with a URL (ie develop.example.com for the develop branch). But if that isn’t possible, I’d like to have a unique URL for an open pull request if possible.

Am I misunderstanding how this is supposed to work and if so, is there a way to get static URLs for (some) preview deployments?

Thanks,

Ben

1 Like

I’m having the same question. This annoys me quite a lot.

My developers are pushing to non-production branches on GitHub and Cloudflare generates a new random URL for each push, how can they (developers) know which URL to access? Given that they are not invited to Cloudflare Dashboard.

Randomized URL should only be used for seeing past builds and there should also be a static URL for each git branch.

Or at least Cloudflare should be able to announce the randomized URL to developers through GitHub or email. I mean we have Cloudflare Access and all, but there’s no way for developers to know the URL?

1 Like

I’m also frustrated by this because static site builds cannot dynamically change the baseURL property. All my links to other pages in my site are generated by using the Hugo {{ .Permalink }} property of the page. This gets translated based on the baseURL of the site. The baseURL is configurable, and can even be set during the build process with the hugo -b $DEPLOY_URL flag. But unfortunately as Pages works right now, my Hugo site preview has links that all point to the configured baseURL, which is my production URL and not the deployed preview URL.

It would be really nice if Cloudflare allowed access to the DEPLOY_URL in the same way that Netlify does for building static sites with Pages.

Hi everyone,

I know that the team has received this feature request already, especially the custom url per branch. It should be coming, but I have no more info than you have yet. Exposing the URL of the deploy might be good, but I haven’t heard of that yet.

You could join their Discord server, there might be info they will share later.

2 Likes

This is super-important to us - as we need all builds from our staging branch (on our GitHub repo) to always exist at a specific sub-domain/URL.

They do appear to do so now. I don’t think it was announced yet, but one of my projects at least seems to have them configured that way.

Hi folks, so this is definitely possible today - you need to check your recent deployments

image

If you click view build, you’ll see an Aliases section which has a fixed URL:

image

This will be the URL for any deployment for this branch. I’ll submit something internally to improve the developer docs to explain this.

1 Like

And I am right in assuming a CNAME to that works as expected? So I can CNAME to a specific deployment?

Not today - since the host header won’t match the branch alias, it will not work. I haven’t tried this yet but I imagine it may be possible with resolve override page rules or worker sub-requests.

1 Like

Even if you add that domain to the custom domains list? I fear the main issue would be the certificate, as the host header wasn’t really an issue before. We’ll see, I need to try it for myself. It was the second to last issue preventing me to move to it fully.

edit it seems to work just fine adding the domain to the list in the Pages dash.

Do you have more than one branch deployed for that pages project? Just want to make sure you’re getting the exact branch you expect.

Yes, I have the main and the development branch. The main is empty (which results in a 523, obviously), the development works just fine. Until I added development. in front of the pages.dev subdomain it didn’t work.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.