knowledge-repo icon indicating copy to clipboard operation
knowledge-repo copied to clipboard

Unable to set context route when deploying

Open Rendiere opened this issue 7 years ago • 5 comments

Auto-reviewers: @NiharikaRay @matthewwardrop @earthmancash @danfrankj

Link to this issue on SO: link

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 APPLICATION_ROOT 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 running knowledge_repo deploy, but can't seem to find anything that does the trick.

Rendiere avatar Feb 09 '18 09:02 Rendiere

@Rendiere I also wanted to do the same as you wanted. I forked and did some changes and its working for me. Here are the changes that I did to make it work. I am not sure if I have connected all the routes with jinja templating correctly.If I have missed please let me know. Here are the changes that I did to make it work.

GeorgeSabu avatar Feb 24 '18 16:02 GeorgeSabu

@GeorgeSabu can you please make a PR for those changes? Or have you already?

buchanae avatar May 10 '18 01:05 buchanae

@buchanae I have not raised a PR. I will do it soon. Little busy this week.

GeorgeSabu avatar May 10 '18 03:05 GeorgeSabu

Any update on this issue? Was a fix merged?

Ahmed1Ossama13 avatar Jul 26 '20 15:07 Ahmed1Ossama13

@Ahmed1Ossama13 I don't believe this has been incorporated into the code. If you submit a PR with the changes @GeorgeSabu made https://github.com/GeorgeSabu/knowledge-repo/commit/63196ad028ef30bdfe8a76e5c5636461297d7750 happy to review & merge

bulam avatar Jul 30 '20 04:07 bulam