π v1.25.0 β Unified Environment Detection & Hardened Audit CSP
β¨ Added
-
Unified environment detection utility (
src/lib/utils/env.js)- Normalizes
process.env/import.meta.envusage across server & client. - Provides consistent flags:
isDev,isProd,isAudit,isCI,isTest. - Fully typed with JSDoc and safe for browser contexts.
- Normalizes
-
Hybrid analytics guard in
posthog.js- Disables tracking automatically in
auditmode or on*.audit.netwk.pro. - Centralized environment logic via
detectEnvironment().
- Disables tracking automatically in
π Changed
-
CSP overhaul for audit mode (
hooks.server.js)- Removes analytics domains and routes CSP reports to
/api/mock-csp. - Preserves full HSTS and core production security headers.
- Clear separation between
test,audit, andprodmodes.
- Removes analytics domains and routes CSP reports to
-
Refined environment handling
- Prevents mismatched behavior between SSR and client builds.
- Fallbacks gracefully to
'unknown'when unset.
-
Branch Guard workflow improvements
- Skips merge commits and Dependabot updates.
- Cleaner logs, lighter permissions, and reliable protection checks.
π Fixed
- Resolved client crash from
process.envin browser context.- Defensive
processchecks prevent runtime reference errors.
- Defensive
π§ Developer Experience
- Simplified environment config across analytics, CSP, and runtime logic.
- Verified
.env.audit/PUBLIC_ENV_MODEcompatibility with Vercel builds.
Deployment Note:
For audit builds, ensure Vercel includes:
ENV_MODE=audit
PUBLIC_ENV_MODE=auditAudit deployments now retain full HTTPS and CSP security β without telemetry or external reporting.