-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix URL generation to better support serving behind proxy #451
Conversation
Very interesting. I'll have look at this tomorrow. We have found a slightly different solution but maybe this is nicer. |
Discussion #402 seems related. |
The Issue #220 is also related. |
And this pull request: #258 |
@frankie567 for comparison with our internal solution I created #459. What do you think? |
@frankie567 I just pushed a reverse_proxy_demo (see #220 (comment)). Unfortunately with your current solution I just see a blank page when accessing it from behind the reverse proxy. It seems like |
To make it work with this solution, the
I've it working that way on a project with Docker and Traefik. |
Ah of course. Setting |
I see, that's indeed an unusual use-case 🤔 Well, I'll let you choose the best solution then. |
Ok, I think the |
#389 is also offering a solution |
Objective
Currently, it's very hard to serve a JustPy app behind a reverse proxy.
Typically, if we want to serve the JustPy app under a path prefix. In ASGI apps, this can be handled thanks to the
root_path
parameter. There is a very good rationale about this in the FastAPI documentation: https://fastapi.tiangolo.com/advanced/behind-a-proxy/However, for this to work, we need to make sure every URL are generated properly, especially by using the
url_for
function of Starlette.Currently, there are many places where the URL is manually built.
Changes
The presented changes try to solve this.
main.html
script. For this to work, we had to add thename
parameter to the WebSocket route./templates/local
folder now have a dynamically generated URL.Feel free to make some comments about this; I'll be happy to improve my proposal so it fits well in the project.