You are currently viewing the new Anvil Editor Docs.
Switch to the Classic Editor Docs
You are currently viewing the Classic Editor Docs.
Switch to the new Anvil Editor Docs main page

Choosing your app’s URL

You can keep the default randomised, private URL or make your app public and choose a human-readable URL.

Publish privately

Your app is automatically published to a private URL of the format:

https://<something>.anvil.app/<private_key>

The <private_key> has sufficient entropy to be unguessable.

To see the private URL, click on ‘Publish app’ in the Gear Menu in the App Browser:

The Publish dialog with Publish Privately selected. A randomised URL with sufficient entropy to be unguessable is displayed.

You can regenerate the <private_key> part by clicking the ‘Reset Link’ button in the Publish App dialog. This ensures anybody who has previously been given the private link can no longer see the app, unless you share the new link with them.

Publish publicly

To publish an app publicly, click on ‘Share via public link’:

The Publish dialog with Publish Publicly selected. A human-readable URL is displayed.

By default, your app is assigned an auto-generated hostname composed of three words followed by anvil.app, e.g. happy-ancient-friend.anvil.app. If you’re on a paid plan, you can modify the part before anvil.app and use a domain name of your choice, replacing anvil.app with your own domain.

Using your own domain name

Custom domains are available on the Hobby Plan and above.

To use a custom domain, create a DNS A record pointing your domain to 52.56.203.177, and enter your domain in the box provided in the Publish App dialog.

The Custom Domain part of the Publish dialog. There is a box to enter your custom domain.

If you wish to use a subdomain of the domain you purchased (such as app.mydomain.com), you can simply configure an A record pointing that subdomain to the IP address above. To configure a subdomain, just enter the subdomain in place of the @ symbol when configuring the A record.

If you want to use www.mydomain.com as well as mydomain.com, you can configure a second A record for www.

DNS changes take a while to propagate around the internet, so you may need to wait up to 48 hours before your changes fully take effect.

Here are some tips on using a custom domain for some common domain registrars:

Google Domains

Google Domains refers to the record you need to create as a ‘Custom Resource Record’.

Google Domains and Synthetic Records

Advanced note: If you’re using a Synthetic Record as a redirect, you need to enable SSL. This because Anvil uses HSTS to enforce SSL as part of its security model (so non-SSL connections will not work by design).

GoDaddy

In the GoDaddy DNS Management page for your domain, you can create an A record in the ‘Records’ card:


Cloudflare

In Cloudflare’s DNS settings tab, add an A record in the ‘add record’ tool.

Cloudflare and SSL

The cloud icon next to the ‘add’ button toggles Cloudflare’s CDN and other features on or off. Anvil apps will work with either setting. If you’re using Cloudflare’s SSL support, you need change the SSL Support setting from ‘Flexible’ to ‘Full Strict’. See this article from Cloudflare for more info. It will take a few minutes to take effect.

Getting your domain in code

You can get your app’s domain name programmatically using anvil.server.get_app_origin(). This will always return the .anvil.app domain, which guarantees to give you something that works regardless of DNS settings.

If you wish to programmatically construct URLs containing your custom domain, hard-code a constant containing your custom domain and construct URLs from that.


Do you still have questions?

Our Community Forum is full of helpful information and Anvil experts.