@ews-admin/global-design-system 1.28.0 → 1.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -679,6 +679,11 @@ interface EnvConfig {
679
679
  * For local development, sensible defaults are provided but can be overridden
680
680
  * (e.g. to point BFF URL at a mock server).
681
681
  *
682
+ * When env is empty (build without VITE_ENV), the environment is derived from
683
+ * the current host instead of always assuming local, so a deployed build never
684
+ * links to http://local.*.medecine360local.com. A console warning names the
685
+ * derived environment so the misconfigured build stays visible.
686
+ *
682
687
  * @param env - The environment name (VITE_ENV value)
683
688
  * @param overrides - Optional URL overrides (e.g. for local mock servers)
684
689
  */
package/dist/index.esm.js CHANGED
@@ -38,6 +38,29 @@ function buildUrls(environment) {
38
38
  adminUrl: `https://${prefix}admin.${domain}`,
39
39
  };
40
40
  }
41
+ /**
42
+ * Derives the environment from the host the app is served from, for builds
43
+ * that did not set VITE_ENV. Hosts actually served (Traefik rules in
44
+ * infrastructure/medecine360-hetzner/deployment/docker-stack.*.yml):
45
+ * - local: localhost, 127.0.0.1, *.medecine360local.com (local.app., api., ...)
46
+ * - dev: dev.{app,login,dashboard,admin,api}.medecine360.com
47
+ * - qa: qa.{app,login,dashboard,admin,api}.medecine360.com
48
+ * - prod: medecine360.com, {login,dashboard,admin,api}.medecine360.com
49
+ * Any other host (or no window, e.g. SSR or tests) falls back to local.
50
+ */
51
+ function environmentFromHost() {
52
+ const hostname = typeof window !== "undefined" ? window.location?.hostname?.toLowerCase() : undefined;
53
+ if (!hostname)
54
+ return "local";
55
+ if (hostname === "medecine360.com" || hostname.endsWith(".medecine360.com")) {
56
+ if (hostname.startsWith("dev."))
57
+ return "dev";
58
+ if (hostname.startsWith("qa."))
59
+ return "qa";
60
+ return "prod";
61
+ }
62
+ return "local";
63
+ }
41
64
  /**
42
65
  * Creates an environment configuration with all derived URLs.
43
66
  *
@@ -47,11 +70,20 @@ function buildUrls(environment) {
47
70
  * For local development, sensible defaults are provided but can be overridden
48
71
  * (e.g. to point BFF URL at a mock server).
49
72
  *
73
+ * When env is empty (build without VITE_ENV), the environment is derived from
74
+ * the current host instead of always assuming local, so a deployed build never
75
+ * links to http://local.*.medecine360local.com. A console warning names the
76
+ * derived environment so the misconfigured build stays visible.
77
+ *
50
78
  * @param env - The environment name (VITE_ENV value)
51
79
  * @param overrides - Optional URL overrides (e.g. for local mock servers)
52
80
  */
53
81
  function createEnvConfig(env, overrides) {
54
- const environment = (env || "local");
82
+ let environment = env;
83
+ if (!environment) {
84
+ environment = environmentFromHost();
85
+ console.warn(`[env-config] VITE_ENV is not set; using "${environment}" derived from the current host.`);
86
+ }
55
87
  const derived = buildUrls(environment);
56
88
  return {
57
89
  env: environment,