Support wildcard patterns and regex in CORS configuration #14154
antoinekm
started this conversation in
Feature Requests & Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Current Behavior
Payload v3's CORS configuration only supports:
'*'
(allows all origins)string[]
(requires exact match)CORSConfig
object withorigins: '*' | string[]
Problem
When working with dynamic development environments where developers have individual subdomains (e.g.,
alice-dev.example.com
,bob-dev.example.com
), the current CORS implementation forces you to either:'*'
in development - Too permissive, security concernUse Case
Real-world scenario:
https://app.tonightpass.com
https://staging.tonightpass.com
https://alice-dev.tonightpass.com
,https://bob-dev.tonightpass.com
Currently, we must use
cors: '*'
in development, which defeats the purpose of CORS protection.Proposed Solution
Support pattern matching similar to Express CORS middleware:
Option 1: Regex patterns
Option 2: Wildcard strings with glob pattern
Option 3: Custom validation function
Benefits
'*'
in developmentWorkaround (Current)
References
Would love to see this feature in Payload v3! Happy to contribute if there's interest.
Beta Was this translation helpful? Give feedback.
All reactions