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

Find API endpoints as dynamically as swagger.json #2770

Open
Timovzl opened this issue Mar 1, 2024 · 0 comments
Open

Find API endpoints as dynamically as swagger.json #2770

Timovzl opened this issue Mar 1, 2024 · 0 comments
Labels
help-wanted A change up for grabs for contributions from the community

Comments

@Timovzl
Copy link

Timovzl commented Mar 1, 2024

Swashbuckle includes a beautiful feature that allows swagger.json to be found completely dynamically: if its specified URL is relative, then the client makes it absolute based on where it is accessing index.html:

item.url = window.location.href.replace("index.html", item.url).split('#')[0];

This takes care of any potential proxy issues, no matter how convoluted. I'd love to see the same for the actual API endpoints!

To give some context, my setup is as follows:

  1. App with Swagger UI is running in Kubernetes, accessible at http://[Whatever]/api/.
  2. Internal proxy forwards https://[InternalHost]/demo/demo-api/api/ to the app.
  3. External proxy forwards https://[ExternalHost]/demo/api to the internal proxy.

As we can see, both host and base path are different each time.

Situation 1 is comparable to running locally, meaning it needs to work correctly. Situation 2 and 3 are also both accessed, so they each need to work correctly as well.

Sadly, the internal proxy does not forward the external proxy's X-Forwarded-* headers in any way. The app does not receive any X-Original-* headers, and the X-Forwarded-* headers are unusable in situation 3.

If the client side would resolve relative API endpoint paths like it does for swagger.json, the issue would be resolved for all cases.

@martincostello martincostello added the help-wanted A change up for grabs for contributions from the community label Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help-wanted A change up for grabs for contributions from the community
Projects
None yet
Development

No branches or pull requests

2 participants