-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
rest-explorer doesn't work behind path-mapping proxy #2285
Comments
This looks like the right solution to me, what downsides do you see yourself? When a LB4 app is running behind a path-mapping proxy, there is no way for LB4 runtime to figure out the URL where the API is publicly available. That's why we are providing the configuration option
Yes please, that makes a lot of sense to me! I think it was an oversight on my side that the initial implementation assumes the LB4 app is running at a root path.
We can improve in increments. Let's start with using the first server entry for the first iteration and wait until there are users asking for more complex rule.
As I understand the matter, |
Thank you for the feedback! In this case I'll put together a PR to implement the |
The prior path turned out to be complicated ... overly so. Replacing with new PR #3133 that takes a simpler path of having the explorer add an additional endpoint for the OAS spec that it can reference via a relative path that is constant in relation to the explorer itself. |
Description / Steps to reproduce / Feature proposal
The
rest-explorer
component doesn't work if the app is behind a proxy that does path mapping -- e.g. external requests made tohttps://example.com/servicename/api-endpoint
, which is mapped tohttp://localhost:3000/api-endpoint
in a docker container or the like. There is no way to make the explorer component or the external explorer redirect work in this environment that I can find.Current Behavior
In the normal setup, the explorer tells the client to load
/openapi.json
, which doesn't work, because it needs to loadhttps://example.com/servicename/openapi.json
. The external redirect has the same problem.Expected Behavior
openapi.json
correctly references paths when behind a proxy that inserts a path prefixrest-explorer
component to work in this context tooOther Notes
This is loosely related to #1702 but that only dealt with host/port issues, not path issues.
This is more closely related to #914
Internally we do not want to use the externally hosted API explorer, but the issues with the base path in the API spec serving mean that I couldn't make that work either even if I wanted to.
Workaround & possible fix?
I was able to work around this, but it is not pretty:
rest.openApiSpec.servers
to reflect the proxy path mapping -- this seems to be roughly equivalent to the LB2 config item, and seems reasonableExplorerController
class with a local sub-class that patches its privateopenApiSpecUrl
member to be aware of therest.openApiSpec.servers
value, and setup the app binding to use this class instead of the normal one. Similarly also had to patch up theindexRedirect
method to be aware of this path prefix.The second item is rather icky given the class I'm extending is not exported, and the member I'm modifying is private.
However, making the normal
ExplorerController
aware of theopenApiSpec.servers
list seems like it might be a reasonable fix for this? However doing that "for real" has some issues I'm not sure how to address:openApiSpec.setServersFromRequest
is enabled? The logic that handles that is not available to theExplorerController
, and it's not clear to me how that should interact with this concern. On the other hand, the way that feature works would not play nice with a proxy that inserts path components, so maybe that is a moot question?The text was updated successfully, but these errors were encountered: