This post has to do with deploying AirBnBs knowledge repo app.
We are hosting our knowledge-repo on a sub-route of our server - for example https://aws.our-server-uri.com/knowledge-repo
and I'm running into issues with loading static content and redirects.
In summary, I have no way of making the knowledge_repo Flask app aware that the app is running on a sub-route.
The issues
The first issue I ran into was making gunicorn aware of the context route in order to successfully locate the static files, which are now at /knowledge-repo/static/...
and not relative to the root url. I solved this by setting the SCRIPT_NAME
environment variable to /knowledge-repo
before running knowledge_repo --repo . deploy
. I'm including this for reference of what I've tried and for potential recommendations of a better solution.
The second issue, which is unresolved, is dynamically prepending our context route to the redirect urls generated by the web app. For example, the Home
button in the top navigation bar redirects the user to the root url (https://aws.our-server-uri.com/
in our example case). I need the flask app to be aware of my context route and append /knowledge-repo/
to the page root for all links generated.
What I've tried:
I want to avoid forking and modifying this repo, so I've focussed on ways that do not involve editing the Flask app html, such as setting a <base>
tag.
- I've set the
SCRIPT_NAME
environment variable before deploying, but to no avail. - I've played around with setting some variables in a
config.py
which I passed using the--config config.py
flag when runningknowledge_repo deploy
, but can't seem to find anything that does the trick.