chore(dx): custom debug host

Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
Innei 2024-11-18 21:36:38 +08:00
parent 6704d61baa
commit a60db7eda6
No known key found for this signature in database
GPG Key ID: 0F62D33977F021F7
2 changed files with 19 additions and 6 deletions

View File

@ -2,7 +2,24 @@
<html>
<head>
<script type="module">
const host = "https://localhost:2233"
const searchParams = new URLSearchParams(window.location.search)
const debugHost = searchParams.get("debug-host")
const resetSessionStorage = () => {
sessionStorage.removeItem("debug-host")
}
const resetParams = searchParams.delete("debug-host")
if (resetParams) {
resetSessionStorage()
}
const debugHostInSessionStorage = sessionStorage.getItem("debug-host")
const host = debugHost || debugHostInSessionStorage || "https://localhost:2233"
if (debugHost) {
sessionStorage.setItem("debug-host", debugHost)
}
const createRefreshRuntimeScript = `
import RefreshRuntime from "${host}/@react-refresh";

View File

@ -63,8 +63,4 @@ injectEnv({"VITE_API_URL":"${apiUrl}","VITE_EXTERNAL_API_URL":"${apiUrl}","VITE_
document.head.prepend($script)
}
const apiMap = {
"https://dev.follow.is": "https://api.dev.follow.is",
"https://app.follow.is": "https://api.follow.is",
}
injectScript(apiMap[window.location.origin])
injectScript(import.meta.env.VITE_API_URL)