@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.js CHANGED
@@ -58,6 +58,29 @@ function buildUrls(environment) {
58
58
  adminUrl: `https://${prefix}admin.${domain}`,
59
59
  };
60
60
  }
61
+ /**
62
+ * Derives the environment from the host the app is served from, for builds
63
+ * that did not set VITE_ENV. Hosts actually served (Traefik rules in
64
+ * infrastructure/medecine360-hetzner/deployment/docker-stack.*.yml):
65
+ * - local: localhost, 127.0.0.1, *.medecine360local.com (local.app., api., ...)
66
+ * - dev: dev.{app,login,dashboard,admin,api}.medecine360.com
67
+ * - qa: qa.{app,login,dashboard,admin,api}.medecine360.com
68
+ * - prod: medecine360.com, {login,dashboard,admin,api}.medecine360.com
69
+ * Any other host (or no window, e.g. SSR or tests) falls back to local.
70
+ */
71
+ function environmentFromHost() {
72
+ const hostname = typeof window !== "undefined" ? window.location?.hostname?.toLowerCase() : undefined;
73
+ if (!hostname)
74
+ return "local";
75
+ if (hostname === "medecine360.com" || hostname.endsWith(".medecine360.com")) {
76
+ if (hostname.startsWith("dev."))
77
+ return "dev";
78
+ if (hostname.startsWith("qa."))
79
+ return "qa";
80
+ return "prod";
81
+ }
82
+ return "local";
83
+ }
61
84
  /**
62
85
  * Creates an environment configuration with all derived URLs.
63
86
  *
@@ -67,11 +90,20 @@ function buildUrls(environment) {
67
90
  * For local development, sensible defaults are provided but can be overridden
68
91
  * (e.g. to point BFF URL at a mock server).
69
92
  *
93
+ * When env is empty (build without VITE_ENV), the environment is derived from
94
+ * the current host instead of always assuming local, so a deployed build never
95
+ * links to http://local.*.medecine360local.com. A console warning names the
96
+ * derived environment so the misconfigured build stays visible.
97
+ *
70
98
  * @param env - The environment name (VITE_ENV value)
71
99
  * @param overrides - Optional URL overrides (e.g. for local mock servers)
72
100
  */
73
101
  function createEnvConfig(env, overrides) {
74
- const environment = (env || "local");
102
+ let environment = env;
103
+ if (!environment) {
104
+ environment = environmentFromHost();
105
+ console.warn(`[env-config] VITE_ENV is not set; using "${environment}" derived from the current host.`);
106
+ }
75
107
  const derived = buildUrls(environment);
76
108
  return {
77
109
  env: environment,