Django deployment with Zappa - root URL is wrong

688 Views Asked by At

I have successfully set up a Django app following a Zappa tutorial I found. However, the problem is that Zappa deploys my app to the location:

 https://some-aws-address/devel

where "devel" is the name of my particular Zappa deployment.

The problem with this is that, at this position, I have pages that have links on them beginning with a '/' that map to:

 https://some-aws-address/ 

and not (as I would want):

https://some-aws-address/devel 

For example, in one of my template files I have a link on an image:

<a href="/"><img src="{% static 'images/main/ryzosens-logo-white-background.png' %}"></a>

where the href="/" always maps to https://some-aws-address/

I don't want to have to do some hack to get my root URLS to map to https://some-aws-address/devel, so the question is:

What must I have in my Django settings (or elsewhere) so that my URL root '/' maps to the HTTP endpoint that Zappa creates?

Many thanks in advance!

1

There are 1 best solutions below

3
Antoine On

The URL suffix is an API Gateway convention: it automatically appends the mandatory stage name to the URL.

I don't think there is an API Gateway or Zappa parameters to change it.

It's recommended to use a custom domain and a custom subdomains for each stage. Thus you can choose a user-friendly URL that matches your needs.

You can also update your STATIC_URL to include the stage. One way to do it is to add the stage as an environment variable and write something like this in your settings.py:

STATIC_URL = os.environ.get("STAGE") + "/static/"

Although I recommend to use a custom domain so you have more control.