Fix codespace url (#3436)

* Fix codespace url (https://github.com/louislam/uptime-kuma/pull/3432#discussion_r1265120809)
This commit is contained in:
Louis Lam
2023-07-17 20:14:05 +08:00
committed by GitHub
parent 278b88a9d9
commit 8e72d6f534
3 changed files with 15 additions and 7 deletions

View File

@@ -83,12 +83,19 @@ export function getResBaseURL() {
export function isDevContainer() {
// eslint-disable-next-line no-undef
return (typeof DEVCONTAINER === "number" && DEVCONTAINER === 1);
return (typeof DEVCONTAINER === "string" && DEVCONTAINER === "1");
}
/**
* Supports GitHub Codespaces only currently
*/
export function getDevContainerServerHostname() {
// replace -3000 with -3001
return location.hostname.replace(/-3000\.preview\.app\.github\.dev/, "-3001.preview.app.github.dev");
if (!isDevContainer()) {
return "";
}
// eslint-disable-next-line no-undef
return CODESPACE_NAME + "-3001." + GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN;
}
/**