diff --git a/Dockerfile b/Dockerfile index abac60b..cca0e12 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,8 @@ FROM nginx:1.27-alpine COPY nginx.conf /etc/nginx/conf.d/default.conf COPY --from=builder /app/dist/humainFlow-gui-a21/browser /usr/share/nginx/html +COPY docker/40-runtime-config.sh /docker-entrypoint.d/40-runtime-config.sh +RUN chmod +x /docker-entrypoint.d/40-runtime-config.sh EXPOSE 80 diff --git a/docker/40-runtime-config.sh b/docker/40-runtime-config.sh new file mode 100644 index 0000000..9e579f8 --- /dev/null +++ b/docker/40-runtime-config.sh @@ -0,0 +1,8 @@ +#!/bin/sh +set -eu + +cat >/usr/share/nginx/html/runtime-config.js <) => string; remove: (widgetId: string) => void; @@ -50,7 +53,7 @@ export class Signup extends FormUtility implements AfterViewInit, OnDestroy { isRegistering = signal(false); captchaToken = signal(null); captchaLoading = signal(false); - captchaEnabled = !!String(environment.turnstileSiteKey ?? '').trim(); + captchaEnabled = environment.turnstileEnabled; private captchaWidgetId: string | null = null; constructor() { @@ -158,7 +161,7 @@ export class Signup extends FormUtility implements AfterViewInit, OnDestroy { } private async mountCaptcha() { - const siteKey = String(environment.turnstileSiteKey ?? '').trim(); + const siteKey = this.turnstileSiteKey(); const container = this.captchaContainer()?.nativeElement; if (!siteKey || !container) return; @@ -227,4 +230,8 @@ export class Signup extends FormUtility implements AfterViewInit, OnDestroy { window.turnstile.reset(this.captchaWidgetId); } } + + private turnstileSiteKey(): string { + return String(window.__runtimeConfig?.turnstileSiteKey ?? '').trim(); + } } diff --git a/src/environments/environment.development.ts b/src/environments/environment.development.ts index 4348e90..e7e42e7 100644 --- a/src/environments/environment.development.ts +++ b/src/environments/environment.development.ts @@ -11,7 +11,7 @@ export const environment = { apiUrl: 'http://localhost:8080', assistantEnabled: false, tourModeAlwaysOn: true, - turnstileSiteKey: '', + turnstileEnabled: false, authorizationCallService: AuthorizationCallFakeService, // Assign the appropriate service here assistantCallService: AssistantCallServiceFake, flowsCallService: FlowsCallServiceFake, diff --git a/src/environments/environment.staging.ts b/src/environments/environment.staging.ts index 12555f8..b07f5fa 100644 --- a/src/environments/environment.staging.ts +++ b/src/environments/environment.staging.ts @@ -11,7 +11,7 @@ export const environment = { apiUrl: 'http://localhost:8080', assistantEnabled: true, tourModeAlwaysOn: false, - turnstileSiteKey: '', + turnstileEnabled: false, assistantCallService: AssistantCallService, authorizationCallService: AuthorizationCallService, flowsCallService: FlowsCallService, diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 67671a5..8ad6e5e 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -11,7 +11,7 @@ export const environment = { production: true, assistantEnabled: false, tourModeAlwaysOn: false, - turnstileSiteKey: '', + turnstileEnabled: true, authorizationCallService: AuthorizationCallService, assistantCallService: AssistantCallService, flowsCallService: FlowsCallService, diff --git a/src/index.html b/src/index.html index 94817ab..2e1fcd8 100644 --- a/src/index.html +++ b/src/index.html @@ -6,6 +6,7 @@ + diff --git a/src/runtime-config.d.ts b/src/runtime-config.d.ts new file mode 100644 index 0000000..fd6f499 --- /dev/null +++ b/src/runtime-config.d.ts @@ -0,0 +1,9 @@ +declare global { + interface Window { + __runtimeConfig?: { + turnstileSiteKey?: string; + }; + } +} + +export {};