Get_app_origin gives wrong domain

I have an app published on a custom domain .app. The application works there correctly.
However, If I use get_app_origin() it still returns .anvil.app. I’m using this to generate share links so I want them to include the custom domain. I’m sure this was working before but it doesn’t now.

Is this a bug? Do I need to configure something?

2 Likes

get_app_origin() is designed to return the .anvil.app domain so that it returns something that’s guaranteed to work regardless of DNS settings. I recommend you hard-code a constant containing your custom domain and refer to that when generating share links.

(I notice this isn’t very well documented, so I’m adding a note to the docs!)

That’s not cool. I was really hoping it was more like Flask’s url_for(_external=True). Certainly there should be some way to extract the base url from the current request.

Can that be a feature request please?

I hate having to change actual code between development and production.

Moving to Feature Requests, thanks for the input.

As usual, we prioritise more popular feature requests more highly, so please ‘like’ this thread if this is important to you.

If it’s particularly important to you, you can sponsor its implementation. We also prioritise requests from those on support contracts. Contact us at support@anvil.works to discuss both of these options.

4 Likes