devex: easier to target backend in dev

This commit is contained in:
Hanashi
2026-08-08 16:40:02 -04:00
parent 9646a791aa
commit 480c073c54
4 changed files with 42 additions and 7 deletions
+9 -5
View File
@@ -21,11 +21,15 @@ if (import.meta.env.DEV) {
StorytellerApiHostStore.getInstance().setApiSchemeAndHost(
window.location.origin,
);
// NB: This is for Brandon to test with storyteller-web locally:
// (disabled — it overrides the origin above and points at localhost:12345,
// which breaks dev unless a local backend is running. Re-enable only when
// testing against a local storyteller-web.)
//StorytellerApiHostStore.getInstance().setDevelopment();
// Backend devs: launch with USE_LOCAL_API=1 (see
// script/website/unix_frontend_webapp_dev.sh) to point API calls at a
// local storyteller-web (http://localhost:12345). When unset — the
// frontend-dev default — this branch never runs and API calls hit
// production. Do not comment this in or out; set the env var instead.
const useLocalApi = import.meta.env.VITE_USE_LOCAL_API;
if (useLocalApi === "1" || useLocalApi === "true") {
StorytellerApiHostStore.getInstance().setDevelopment();
}
} catch (e) {
console.warn("Failed to set dev API host override", e);
}
+9 -2
View File
@@ -21,8 +21,15 @@ if (import.meta.env.DEV) {
StorytellerApiHostStore.getInstance().setApiSchemeAndHost(
window.location.origin,
);
// NB: This is for Brandon to test with storyteller-web locally:
StorytellerApiHostStore.getInstance().setDevelopment();
// Backend devs: launch with USE_LOCAL_API=1 (see
// script/website/unix_frontend_website_dev.sh) to point API calls at a
// local storyteller-web (http://localhost:12345). When unset — the
// frontend-dev default — this branch never runs and API calls hit
// production. Do not comment this in or out; set the env var instead.
const useLocalApi = import.meta.env.VITE_USE_LOCAL_API;
if (useLocalApi === "1" || useLocalApi === "true") {
StorytellerApiHostStore.getInstance().setDevelopment();
}
} catch (e) {
console.warn("Failed to set dev API host override", e);
}
@@ -24,6 +24,18 @@ frontend_npm_install
export VITE_ENVIRONMENT_TYPE="production"
# Backend devs: launch with USE_LOCAL_API=1 (or `export USE_LOCAL_API=1` once
# in your shell profile) to point the frontend at a local storyteller-web on
# http://localhost:12345. Unset/0 — the frontend-dev default — hits
# production. This replaces the comment/uncomment dance around
# StorytellerApiHostStore.setDevelopment() in src/main.tsx.
export VITE_USE_LOCAL_API="${USE_LOCAL_API:-0}"
if [[ "${VITE_USE_LOCAL_API}" == "1" ]]; then
echo "USE_LOCAL_API=1 — API calls will target http://localhost:12345"
else
echo "API calls will target production (set USE_LOCAL_API=1 for a local backend)"
fi
nx dev artcraft-webapp
popd || exit
@@ -24,6 +24,18 @@ frontend_npm_install
export VITE_ENVIRONMENT_TYPE="production"
# Backend devs: launch with USE_LOCAL_API=1 (or `export USE_LOCAL_API=1` once
# in your shell profile) to point the frontend at a local storyteller-web on
# http://localhost:12345. Unset/0 — the frontend-dev default — hits
# production. This replaces the comment/uncomment dance around
# StorytellerApiHostStore.setDevelopment() in src/main.tsx.
export VITE_USE_LOCAL_API="${USE_LOCAL_API:-0}"
if [[ "${VITE_USE_LOCAL_API}" == "1" ]]; then
echo "USE_LOCAL_API=1 — API calls will target http://localhost:12345"
else
echo "API calls will target production (set USE_LOCAL_API=1 for a local backend)"
fi
nx dev artcraft-website
popd || exit