doccano
doccano copied to clipboard
Add option to serve with URL prefix
Added the option to run Doccano with a URL prefix instead of always running from the domain root. The prefix is configured by specifying a BASE_URL
environment variable. This PR fixes #1878
To run Doccano under /doccano/
, set BASE_URL
to /doccano/
:
export BASE_URL=/doccano/
When we now compile the front-end, all routes are prefixed with BASE_URL.
We also need to let Django know about our new prefix. This is done using the same BASE_URL environment variable but needs to be set during runtime. I could not find a clean method to configure them both during runtime.
Since such a configuration will most likely only be used in combination with a load balancer, I also added the option to set USE_X_FORWARDED_HOST
using environment variables.
Note that I did not write any tests for this (yet), both because I am unsure how this should be done and because I would first like to know if this PR would be acceptable.
Thanks!
Please write some test cases. After that, I'll merge this PR.
Great, will do. Any tips about where to start for someone unfamiliar with the project (and Django in general)? I expect I should extend backend/api/tests/test_config.py
?
Still in progress? @Vinno97
This hasn't been on my radar for quite a long time. The project I needed this fix for, was finished up a while ago. I'd be willing to write some tests for it, but I'm still equally unfamiliar with the project and Django. So some pointers will be needed