server/security.ts view source
(env_value: string | undefined): RegExp[] Parses ALLOWED_ORIGINS env var into regex matchers for request source verification. This is NOT a CSRF protection mechanism - it's a simple origin/referer allowlist that verifies requests are coming from expected sources.
Accepts comma-separated patterns with limited wildcards:
- Exact origins: https://api.example.com
- Wildcard subdomains: https://*.example.com (matches exactly one subdomain level)
- Multiple wildcards: https://*.staging.*.example.com (for deep subdomains)
- Wildcard ports: http://localhost:* (matches any port or no port)
- IPv6 addresses: http://[::1]:3000, https://[2001:db8::1]
- Combined: https://*.example.com:*
Examples:
- http://localhost:3000,https://prod.example.com
- https://*.api.example.com,http://127.0.0.1:*
- http://[::1]:*,https://*.*.corp.example.com:*
env_value
string | undefinedreturns
RegExp[]