Inject html base tag directly (#1967)

Using a script to inject the base tag is unnecessarily complex as well as it is introducing an issue where the initial requests will potentially fail, due to the base tag not being injected yet.

See https://github.com/Suwayomi/Suwayomi-WebUI/issues/1096, same issue applies when a subpath is set up which can't be fixed on the client side
This commit is contained in:
schroda
2026-05-02 23:21:23 +02:00
committed by GitHub
parent 031890deb6
commit 5cda584568

View File

@@ -206,20 +206,12 @@ object WebInterfaceManager {
if (ServerSubpath.isDefined() && orgIndexHtml.exists()) {
val originalIndexHtml = orgIndexHtml.readText()
val subpathInjectionScript =
"""
<script>
// <<suwayomi-subpath-injection>>
const baseTag = document.createElement('base');
baseTag.href = location.origin + "${ServerSubpath.asRootPath()}";
document.head.appendChild(baseTag);
</script>
""".trimIndent()
val subpathInjectionBaseTag = "<base href=\"${ServerSubpath.asRootPath()}\">"
val indexHtmlWithSubpathInjection =
originalIndexHtml.replace(
"<head>",
"<head>$subpathInjectionScript",
"<head>$subpathInjectionBaseTag",
)
orgIndexHtml.writeText(indexHtmlWithSubpathInjection)