Skip to content
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

CheckWronglyVersionedBaseUrls middleware not working for Dockerized servers #520

Closed
CasperWA opened this issue Sep 24, 2020 · 3 comments
Closed
Labels
bug Something isn't working needs discussion priority/high Issue or PR with a consensus of high priority server Issues pertaining to the example server implementation

Comments

@CasperWA
Copy link
Member

The middleware CheckWronglyVersionedBaseUrls cannot properly handle servers that run in Docker and may be proxied through to a different "public" base URL.

The issue here is the reliance on the utility function get_base_url, which will either return the CONFIG.base_url if not None, otherwise it will return the parsed URL without a path.

If the server is running in Docker, it will likely run at http://localhost:5000 or http://0.0.0.0 and be proxied through to the configure base URL, which will also be used in the configuration of the server, i.e., the proxied "public" base URL will be the value of CONFIG.base_url, which it also needs to be for other parts of the server to deliver the correct links (e.g., for pagination, etc.).

A solution here is to try and retrieve the actual base URL that the server understands it is running at if possible from uvicorn. However, since one may use other servers than uvicorn, this is not a general solution. Instead one should perhaps add another configuration entry docker_base_url or local_base_url?

@CasperWA CasperWA added bug Something isn't working priority/high Issue or PR with a consensus of high priority server Issues pertaining to the example server implementation labels Sep 24, 2020
@CasperWA CasperWA changed the title CheckWronglyVersionedBaseUrls middelware not working for Dockerized servers CheckWronglyVersionedBaseUrls middleware not working for Dockerized servers Sep 24, 2020
@ml-evs
Copy link
Member

ml-evs commented Oct 2, 2020

I think something similar is also affecting the HandleApiHint middlware; if I try https://optimade-test.odbx.science/info?api_hint=v1, it gets transformed into https://optimade-test.odbx.science/v1info. Will investigate.

@CasperWA
Copy link
Member Author

CasperWA commented Oct 3, 2020

I think something similar is also affecting the HandleApiHint middlware; if I try https://optimade-test.odbx.science/info?api_hint=v1, it gets transformed into https://optimade-test.odbx.science/v1info. Will investigate.

This seems more like an issue with handling the suffixed / when creating the new URL in the HandleApiHint middleware. But granted, it might be related.

@ml-evs
Copy link
Member

ml-evs commented Oct 3, 2020

You're probably right, just perplexed as to why it works locally but not in Docker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs discussion priority/high Issue or PR with a consensus of high priority server Issues pertaining to the example server implementation
Projects
None yet
Development

No branches or pull requests

2 participants