Add support for Codespaces (#3432)

* Create devcontainer.json

* WIP

* WIP

* WIP

* Create README.md

* Try to fix cypress issue

* Add extensions

* WIP

* Minor
This commit is contained in:
Louis Lam
2023-07-17 14:54:40 +08:00
committed by GitHub
parent 25c8196641
commit 084cf01fcd
7 changed files with 72 additions and 3 deletions

View File

@@ -72,13 +72,25 @@ export function setPageLocale() {
*/
export function getResBaseURL() {
const env = process.env.NODE_ENV;
if (env === "development" || localStorage.dev === "dev") {
if (env === "development" && isDevContainer()) {
return location.protocol + "//" + getDevContainerServerHostname();
} else if (env === "development" || localStorage.dev === "dev") {
return location.protocol + "//" + location.hostname + ":3001";
} else {
return "";
}
}
export function isDevContainer() {
// eslint-disable-next-line no-undef
return (typeof DEVCONTAINER === "number" && DEVCONTAINER === 1);
}
export function getDevContainerServerHostname() {
// replace -3000 with -3001
return location.hostname.replace(/-3000\.preview\.app\.github\.dev/, "-3001.preview.app.github.dev");
}
/**
*
* @param {} mqtt wheather or not the regex should take into account the fact that it is an mqtt uri