https://github.com/coldbox-modules/cors
Add CORS headers to your app in one module
https://github.com/coldbox-modules/cors
Last synced: 4 months ago
JSON representation
Add CORS headers to your app in one module
- Host: GitHub
- URL: https://github.com/coldbox-modules/cors
- Owner: coldbox-modules
- License: mit
- Created: 2017-02-24T16:10:24.000Z (over 9 years ago)
- Default Branch: main
- Last Pushed: 2024-12-12T16:51:53.000Z (over 1 year ago)
- Last Synced: 2025-06-19T14:53:04.974Z (12 months ago)
- Language: ColdFusion
- Homepage:
- Size: 306 KB
- Stars: 5
- Watchers: 3
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# cors
## Add CORS headers to your app in one module
This module detects CORS requests, validates them against the configured origins,
and handles preflight requests.
The following is the default configuration.
```
settings = {
autoRegisterInterceptor = true,
allowOrigins = function( event ) {
return event.getHTTPHeader( "Origin", "*" );
},
allowMethods = function( event ) {
return event.getHTTPMethod();
},
allowHeaders = function( event ) {
return event.getHTTPHeader( "Access-Control-Request-Headers", "" );
},
maxAge = 60 * 60 * 24, // 1 day
allowCredentials = true,
eventPattern = ".*",
shouldReturnPreflight = function( event ) {
return event.isInvalidHTTPMethod( );
}
};
```
## `autoRegisterInterceptor`
If you need more control over the order of your interceptors you can
disable the automatic loading of the CORS interceptor. If you do this
you will need to register it yourself (most likely in `config/ColdBox.cfc`)
as `cors.interceptors.CORS`.