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