Home
Support Forums

Netlify CLI Alias URLs "Not Found"

Netlify CLI alias deploys not working

Hi, submitting builds from our own CI/CD system using the Netlify CLI (2.54.0). We have the autobuild functionality disabled in Netlify, and simply submit the builds after they have completed with the CLI.

We noticed the new release of the CLI supported --alias but this doesn’t seem to be working. The build submits, and the randomly generated URL works, but following the aliased name doesn’t work, despite the fact that the build entry in the Netlify UI links to this:

See here, with the "branch deploy’ hyperlink linking to the Alias URL. But this URL just shows 404 Not Found:
https://feature-netlify-staging--v2-admin-walkin.netlify.app/

What is interesting, is the URL on the “Preview deploy” hyperlink does work:
https://5ef7d9f560043f5327428089--v2-company-website.netlify.app/

Let me known if anyone else has experienced this. It seems like this should be working, since the UI links to it.

This is the command line we execute:
netlify deploy --dir packages/website/build --site $SITEID --alias $BRANCH_NAME--json > deployInfo.json

Hi, @strideynet, there is a forward slash in the $BRANCH_NAME. This results in an invalid subdomain of feature/netlify-staging--v2-company-website.netlify.app.

The CLI tool is correcting that string in the URL shown in the shell but it is sending the uncorrected string to the database. I filed an issue for with with the CLI tool repo (which is public) here:

The only workaround for now is to make certain that whatever is submitted only consists of valid characters for domain names (for example, “/” isn’t a valid domain name character).

If there are other questions about this, please let us know.

Many, many thanks.

I thought I was going crazy :slight_smile:

I have a very similar issue, but the reason is not related to the name of the branch which is dev.
Here my setup:

  • I don’t have branch deploy activated for the branch dev
  • I build the dev branch with Github actions, the I push the build to netlify with the following command netlify deploy --site ${{secrets.NETLIFY_SITE}} --auth ${{secrets.NETLIFY_AUTH}} --message "${{ steps.extract_branch.outputs.branch }}@${{ steps.extract_sha.outputs.sha }}" --alias dev

When I open the deployment in Netlify UI, the preview deploy hyperlink will have the updated version of my website. But the branch deploy hyperlink will point to an older version of my branch (one that was build when I was activating branch context from the Netlify UI). When I download deployed file as a zip, the source code is the right one.

Am I doing anything wrong ?
The API ID of my site is : 3d021ed2-cf41-45d9-8c1d-058198711ff7

Here is the .toml file I have, even if I don’t think it is involved in the deployment since I upload manually the build with netlify cli :

[build]
  base = "./"
  publish = "web-build"

  command = "npm run build-prod"

  [context.staging]
  command = "npm run build-staging"

  [context.dev]
    command = "npm run build-dev"

Hi, @thibault. You may notice that the --branch option is deprecated and replaced with --alias in the netlify-cli help info (for netlify help deploy). I’ve highlighted the two lines below:

  -b, --branch=branch                                          Serves the same functionality as --alias. Deprecated and will be removed in future versions
  --alias=alias                                                Specifies the alias for deployment. Useful for creating predictable deployment URL's

Why was it changed? Because the resulting deploys are not branch deploys.

Long story short, using the --alias option will allow you to get a predictable deploy URL but that deploy is not a branch deploy and cannot be used in conjunction with the branch subdomain feature.

If there are other questions, please let us know.