-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Handle configured API_URLs that have a path: #4995
Conversation
For the case when a user has modified mapboxgl.config.API_URL that includes a path such as http://test.example.com/api.mapbox.com the path was getting removed when building the full URL as it was being overwritten by the original path from the request. This pull request checks if the generation of the apiUrlObject has a path other than '/' (which is the default) we need to prepend it to the original urlObject path. This fixes the case where users using a reverse proxy to mapbox have filtered on the specific path set in their API_URL, and when it has been removed the lack of a match causes the proxy to not forward the requests .
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.
Thanks for the contribution @durran!
src/util/mapbox.js
Outdated
@@ -17,6 +17,10 @@ function makeAPIURL(urlObject: UrlObject, accessToken: string | null | void): st | |||
urlObject.protocol = apiUrlObject.protocol; | |||
urlObject.authority = apiUrlObject.authority; | |||
|
|||
if (apiUrlObject.path !== '/') { | |||
urlObject.authority = `${urlObject.authority}${apiUrlObject.path}`; |
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.
Could this prepend apiUrlObject.path
to urlObject.path
, rather than appending it to authority
? That would be clearer and more robust.
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.
More than happy to make that change.
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.
@jfirebaugh Changes made - we now prepend to the urlObject.path
instead of appending to urlObject.authority
.
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.
Thank you!
Thanks! |
For the case when a user has modified
mapboxgl.config.API_URL
thatincludes a path such as http://test.example.com/api.mapbox.com the
path was getting removed when building the full URL as it was being
overwritten by the original path from the request.
This pull request checks if the generation of the
apiUrlObject
has apath other than
'/'
(which is the default), and if so we need to prepend it to theoriginal
urlObject
path.This fixes the case where users using a reverse proxy to mapbox have
filtered on the specific path set in their API_URL, and when it has been
removed the lack of a match causes the proxy to not forward the requests
.
Debug page:
Benchmarks:
Launch Checklist