The CORS Plugin automatically adds the following headers based on configuration:
Header
Value Source
Description
Access-Control-Allow-Origin
allowed_origins
Specifies allowed origins for cross-origin requests
Access-Control-Allow-Methods
allowed_methods
HTTP methods allowed in cross-origin requests
Access-Control-Allow-Headers
allowed_headers
Headers allowed in cross-origin requests
Access-Control-Expose-Headers
exposed_headers
Headers exposed to client JavaScript
Access-Control-Allow-Credentials
allow_credentials
Whether credentials are allowed
Access-Control-Max-Age
max_age
Preflight cache duration in seconds
Preflight Requests
The CORS Plugin automatically handles OPTIONS preflight requests, responding with appropriate CORS headers without passing the request to subsequent plugins in the pipeline.
Schema Inheritance
This schema inherits from the UtilityPlugin schema, which provides:
logfile - Log file path
directory - Directory configuration
enabled - Plugin enable/disable state
And ultimately from the base Plugin schema, which provides:
library - Plugin library path
plugin - Base plugin reference property
Security Considerations
Security Best Practices
Avoid "*" in Production: Don't use wildcard origins with credentials enabled
Specify Exact Domains: List specific allowed origins instead of wildcards
Limit Methods: Only allow necessary HTTP methods
Restrict Headers: Minimize allowed custom headers
Credential Policies: Be cautious with allow_credentials=true
Common Security Patterns
Use Case
Origins
Credentials
Security Level
Public API
*
false
Low (Open)
Partner API
https://partner.com
false
Medium
Same-Origin Variants
https://app.com,https://www.app.com
true
High
Development
http://localhost:*
false
Development Only
Validation Rules
allowed_origins should contain valid URLs or "*" for wildcard
allowed_methods must contain valid HTTP methods
allowed_headers should contain valid HTTP header names
allow_credentials must be "true" or "false" if specified
max_age must be a positive integer (seconds)
Don't combine wildcard origins ("*") with credentials (security risk)
The name property should be unique if multiple CORS plugins are used
Plugin Pipeline Placement
The CORS Plugin should be placed early in the plugin pipeline, before authentication and authorization plugins. This ensures that preflight OPTIONS requests are handled correctly even for protected resources.