diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index a63e2537..5b3ceabc 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,5 +1,5 @@ { - "image": "mcr.microsoft.com/devcontainers/javascript-node:dev-20-bookworm", + "image": "mcr.microsoft.com/devcontainers/javascript-node:dev-18-bookworm", "features": { "ghcr.io/devcontainers/features/github-cli:1": {} }, @@ -14,8 +14,7 @@ "vscode": { "extensions": [ "streetsidesoftware.code-spell-checker", - "dbaeumer.vscode-eslint", - "GitHub.copilot" + "dbaeumer.vscode-eslint" ] } }, diff --git a/config/vite.config.js b/config/vite.config.js index 5e2c6b22..11c61006 100644 --- a/config/vite.config.js +++ b/config/vite.config.js @@ -17,7 +17,9 @@ export default defineConfig({ }, define: { "FRONTEND_VERSION": JSON.stringify(process.env.npm_package_version), - "DEVCONTAINER": process.env.DEVCONTAINER, + "DEVCONTAINER": JSON.stringify(process.env.DEVCONTAINER), + "GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN": JSON.stringify(process.env.GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN), + "CODESPACE_NAME": JSON.stringify(process.env.CODESPACE_NAME), }, plugins: [ commonjs(), diff --git a/src/util-frontend.js b/src/util-frontend.js index 9b3c1cd1..4b85fa34 100644 --- a/src/util-frontend.js +++ b/src/util-frontend.js @@ -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; } /**