Skip to content

Conversation

@toy
Copy link
Contributor

@toy toy commented Dec 17, 2025

Using only fragment works completely fine unless base tag is added in head (which makes also pushState urls be relative to it instead of to the current url). Fix by constructing complete url relative to current location.

Using only fragment works completely fine unless base tag is added in
head (which makes also pushState urls be relative to it instead of to
the current url). Fix by constructing complete url relative to current
location.
@wparad
Copy link
Member

wparad commented Dec 17, 2025

Can you provide a working reproduction of this problem?

@toy
Copy link
Contributor Author

toy commented Dec 17, 2025

Following would be a minimal reproduction, the fragment will be prefixed with /not/the/path/you/expected/here:

<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <title>OpenAPI Explorer Development Test</title>
    <script src="https://unpkg.com/openapi-explorer/dist/browser/openapi-explorer.min.js" type="module" defer></script>
    <base href="/not/the/path/you/expected/here" />
  </head>
  <body>
    <openapi-explorer spec-url="https://api.authress.io/v1"></openapi-explorer>
  </body>
</html>

@wparad
Copy link
Member

wparad commented Dec 17, 2025

to complete the reproduction can please include these necessary additional pieces:

  • How do you trigger the bug?
  • What do you expect to happen?
  • What actually does happen?

As soon as we get those, we can verify this fix solves the problem. Thanks!

@toy
Copy link
Contributor Author

toy commented Dec 17, 2025

  • How do you trigger the bug?

Having the openapi-explorer rendered at a path on a page with base tag in head with href attribute (by default set to / which is not equal to the path of openapi-explorer page). Example at https://community.openproject.org/api/docs

  • What do you expect to happen?

Reloading the page stays on the openapi explorer page and at the same location inside

  • What actually does happen?

The path from href of base tag is loaded with fragment set by openapi-explorer

@wparad
Copy link
Member

wparad commented Dec 17, 2025

Cool, we support this change.

@wparad wparad merged commit 49d4d32 into Authress-Engineering:release/2.4 Dec 17, 2025
2 checks passed
toy added a commit to opf/openproject that referenced this pull request Dec 18, 2025
openapi-explorer uses pushState with anchor only, but this doesn't work
with base tag, as anchor is added to the base url instead of current
url. So override the replaceState function to construct the full url
based on current location

Probably not needed very soon, as
Authress-Engineering/openapi-explorer#292 was quickly merged
toy added a commit to opf/openproject that referenced this pull request Dec 18, 2025
openapi-explorer uses pushState with anchor only, but this doesn't work
with base tag, as anchor is added to the base url instead of current
url. So override the replaceState function to construct the full url
based on current location

Probably not needed very soon, as
Authress-Engineering/openapi-explorer#292 was quickly merged
toy added a commit to opf/openproject that referenced this pull request Dec 18, 2025
openapi-explorer uses pushState with anchor only, but this doesn't work
with base tag, as anchor is added to the base url instead of current
url. So override the replaceState function to construct the full url
based on current location

Probably not needed very soon, as
Authress-Engineering/openapi-explorer#292 was quickly merged
toy added a commit to opf/openproject that referenced this pull request Dec 19, 2025
openapi-explorer uses pushState with anchor only, but this doesn't work
with base tag, as anchor is added to the base url instead of current
url. So override the replaceState function to construct the full url
based on current location

Probably not needed very soon, as
Authress-Engineering/openapi-explorer#292 was quickly merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants