-
Notifications
You must be signed in to change notification settings - Fork 5
/
ModuleConfig.cfc
38 lines (34 loc) · 1.19 KB
/
ModuleConfig.cfc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
component {
this.name = "cors";
this.author = "Eric Peterson";
this.cfmapping = "cors";
this.webUrl = "https://github.com/elpete/cors";
function configure() {
settings = {
autoRegisterInterceptor = true,
allowOrigins = function( event ) {
return event.getHTTPHeader( "Origin", "*" );
},
allowMethods = function( event ) {
return event.getHTTPHeader( "Access-Control-Request-Method", 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( );
}
};
}
function onLoad() {
if ( settings.autoRegisterInterceptor ) {
controller.getInterceptorService().registerInterceptor(
interceptorName = "CORS",
interceptorClass = "#moduleMapping#.interceptors.CORS"
);
}
}
}