elements icon indicating copy to clipboard operation
elements copied to clipboard

Ability to Disable URL Rewrite

Open Shackelford-Arden opened this issue 3 months ago • 1 comments

Current Situation

In lower/dev environments, hosting Stoplight Elements behind something like a software load balancer/proxy (Traefik/Fabio/Nginx, etc) can sometimes mean that they are accessed via a subfolder-like path.

Example URL: https://lb.internal.fqdn/fancy-app/docs

In the example above, the load balancers can be configured to strip the /fancy-app piece of the request when forwarding the request on to my application.

Today I can get this to work by ensuring the basePath is aware of the /fancy-app URI to properly load the OpenAPI spec provided. I can get the UI to load once by having router="history". However, the moment the page loads, the URL gets re-written to remove the /fancy-app component of the URL.

Once https://lb.internal.fqdn/fancy-app/docs loads, it immediately shows https://lb.internal.fqdn/docs. Using any of the other routers simply fails to load the docs entirely.

My question

Is there a way to configure Stoplight to not rewrite the URL in this scenario? I assume there is something specific to React (or whichever framework Stoplight uses) where this would be configured, if it is even possible.

References

  • #2146 - Got me to the point where I can get things to load by setting basePath.

Current Config

<!doctype html>
<html lang="en">
<head>
	<meta charset="utf-8" />
	<meta name="referrer" content="same-origin" />
	<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
	<title>Fancy App API Documentation</title>
	<script src="https://unpkg.com/@stoplight/elements/web-components.min.js"></script>
	<link rel="stylesheet" href="https://unpkg.com/@stoplight/elements/styles.min.css" />
</head>
<body style="height: 100vh;">
	<elements-api
		basePath="/fancy-app"
		apiDescriptionUrl="/api/openapi.json"
		layout="responsive"
		router="history"
		tryItCredentialsPolicy="same-origin"
	/>
</body>
</html>

Shackelford-Arden avatar Mar 22 '24 22:03 Shackelford-Arden

This ticket has been labeled jira. A tracking ticket in Stoplight's Jira (STOP-425) has been created.

github-actions[bot] avatar Apr 02 '24 23:04 github-actions[bot]