-
Notifications
You must be signed in to change notification settings - Fork 44
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
Reflect CONFIG.root_path in get_base_url #663
base: main
Are you sure you want to change the base?
Reflect CONFIG.root_path in get_base_url #663
Conversation
Codecov Report
@@ Coverage Diff @@
## master #663 +/- ##
==========================================
+ Coverage 92.72% 92.80% +0.07%
==========================================
Files 68 67 -1
Lines 3668 3528 -140
==========================================
- Hits 3401 3274 -127
+ Misses 267 254 -13
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
c1837bd
to
72088b9
Compare
This sounds related to #520? |
I am not sure. I think it is different. #520 is about a proxied app that gets a different request url from the proxy than from "outside". This PR wont fix that. I think this might be cause by wrong proxy config? If you forward the host correctly, the request urls should match the actual "outside" request urls. It least we did not run into issues running this in docker behind a proxy. But it is definitely related to #634 |
There isn't any issues with the added routers either, only the documentation routes added by the FastAPI itself (just a note) :) |
72088b9
to
9fde7a9
Compare
9fde7a9
to
1235326
Compare
I've added a Also, I've added a fix to one issue I found locally already, namely that if trailing slashes ( |
@markus1978 is the expected behaviour that the |
Not sure if this is related, but I recently noticed that http://localhost:5000/v1 returns with a wrong version error on the reference server now (i.e. it doesn't redirect to the landing page) |
while value.endswith("/"): | ||
value = value[:-1] | ||
while value.startswith("/"): | ||
value = value[1:] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while value.endswith("/"): | |
value = value[:-1] | |
while value.startswith("/"): | |
value = value[1:] | |
value = value.strip("/") |
I think it would be better to use strip here as it is shorter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from the comment in config.py, your code looks good to me.
I have, however, just started to work on the Optimade project and there are still plenty of things in the code that I do not know about. So I think it would be best if you wait until you have also received feedback from Matthew or Casper.
The current implementation assumes no API path prefix (e.g.
CONFIG.root_path==None
). If there is a prefix some URLs are wrong.The fix in this PR is on
get_base_url
and also on one use ofget_base_url
. The usages ofget_base_url
assume different things. For the info endpoint the expectation is thatget_base_url
returns a base url including the path prefix (untouched). For the next links in entry list endpoints, the expectation is thatget_base_url
returns the base url with no path at all and it will add the request url's path including the path prefix (fixed here). You could also fix it the other way around.