stoplightio / elements

Build beautiful, interactive API Docs with embeddable React or Web Components, powered by OpenAPI and Markdown.
https://stoplight.io/open-source/elements/
Apache License 2.0
1.74k stars 201 forks source link

Ability to Disable URL Rewrite #2556

Open Shackelford-Arden opened 6 months ago

Shackelford-Arden commented 6 months ago

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

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>
github-actions[bot] commented 6 months ago

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