Voeg Api.AndreaSlopFotografie toe met setup-token, proxy-bewuste limiters en ASF-admin-thema
- Core: opt-in ForwardedHeaders:KnownProxies en rate limiters per clientadres (zonder configuratie ongewijzigd gedrag) - Identity: optioneel setup-token (X-Setup-Token), beide setup-endpoints onder de login-limiter, beveiligingsgebeurtenis setup_token_rejected (5007) - Nieuw client-project SlpModularCms.Api.AndreaSlopFotografie (Identity + Availability) met bijbehorende tests - Frontend: thema asf (VITE_THEME), VITE_DEFAULT_LANGUAGE, tokenveld op de setup-pagina - CI: jobs publish/deploy-asf-test achter ASF_TEST_DEPLOY_ENABLED - Fix U1: 301-Location wordt nu percent-encoded (gevonden door de property-test) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { getAppConfig, resetAppConfigCache } from '@/lib/config';
|
||||
import { getAppConfig, parseDefaultLanguage, resetAppConfigCache } from '@/lib/config';
|
||||
|
||||
/**
|
||||
* The empty-base case is the production configuration, and the one nobody runs locally — so it is
|
||||
@@ -81,3 +81,39 @@ describe('getAppConfig', () => {
|
||||
expect(config.umamiWebsiteId).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('parseDefaultLanguage', () => {
|
||||
it.each([
|
||||
['nl', 'nl'],
|
||||
['en', 'en'],
|
||||
[' NL ', 'nl'],
|
||||
['EN', 'en'],
|
||||
])('accepts %j as %s', (input, expected) => {
|
||||
expect(parseDefaultLanguage(input)).toBe(expected);
|
||||
});
|
||||
|
||||
it.each([undefined, '', ' ', 'de', 'nl-NL', 'dutch'])('treats %j as no default', (input) => {
|
||||
expect(parseDefaultLanguage(input)).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('getAppConfig defaultLanguage', () => {
|
||||
afterEach(() => {
|
||||
vi.unstubAllEnvs();
|
||||
resetAppConfigCache();
|
||||
});
|
||||
|
||||
it('reads VITE_DEFAULT_LANGUAGE', () => {
|
||||
resetAppConfigCache();
|
||||
vi.stubEnv('VITE_DEFAULT_LANGUAGE', 'nl');
|
||||
|
||||
expect(getAppConfig().defaultLanguage).toBe('nl');
|
||||
});
|
||||
|
||||
it('is undefined when VITE_DEFAULT_LANGUAGE is absent', () => {
|
||||
resetAppConfigCache();
|
||||
vi.stubEnv('VITE_DEFAULT_LANGUAGE', undefined as unknown as string);
|
||||
|
||||
expect(getAppConfig().defaultLanguage).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -21,10 +21,17 @@ const configSchema = z.object({
|
||||
appEnv: z.string().optional(),
|
||||
umamiScriptUrl: z.string().optional(),
|
||||
umamiWebsiteId: z.string().optional(),
|
||||
defaultLanguage: z.enum(['en', 'nl']).optional(),
|
||||
});
|
||||
|
||||
export type AppConfig = z.infer<typeof configSchema>;
|
||||
|
||||
/** Only a supported language counts; anything else (typo, empty) means "no default" and falls back to the browser. */
|
||||
export function parseDefaultLanguage(value: string | undefined): 'en' | 'nl' | undefined {
|
||||
const v = value?.trim().toLowerCase();
|
||||
return v === 'en' || v === 'nl' ? v : undefined;
|
||||
}
|
||||
|
||||
let cached: AppConfig | null = null;
|
||||
|
||||
export function getAppConfig(): AppConfig {
|
||||
@@ -43,6 +50,7 @@ export function getAppConfig(): AppConfig {
|
||||
appEnv: import.meta.env.VITE_APP_ENV,
|
||||
umamiScriptUrl: import.meta.env.VITE_UMAMI_SCRIPT_URL,
|
||||
umamiWebsiteId: import.meta.env.VITE_UMAMI_WEBSITE_ID,
|
||||
defaultLanguage: parseDefaultLanguage(import.meta.env.VITE_DEFAULT_LANGUAGE),
|
||||
};
|
||||
|
||||
if (import.meta.env.DEV) {
|
||||
|
||||
Reference in New Issue
Block a user