restify-cors-middleware
Advanced tools
Comparing version 0.0.3 to 0.0.4
{ | ||
"name": "restify-cors-middleware", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"author": "Tabcorp Digital Technology Team", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -11,2 +11,3 @@ # restify-cors-middleware | ||
var cors = corsMiddleware({ | ||
preflightMaxAge: 5 //Optional | ||
origins: ['http://api.myapp.com', 'http://web.myapp.com'], | ||
@@ -13,0 +14,0 @@ allowHeaders: ['API-Token'], |
@@ -45,2 +45,7 @@ var restify = require('restify'); | ||
// 6.2.8 | ||
if (options.preflightMaxAge) { | ||
res.header('Access-Control-Max-Age', options.preflightMaxAge); | ||
} | ||
// 6.2.9 | ||
@@ -58,2 +63,1 @@ res.header('Access-Control-Allow-Methods', allowedMethods.join(', ')); | ||
}; | ||
@@ -87,4 +87,14 @@ // | ||
xit('6.2.8 Access-Control-Max-Age not supported', function(done) { | ||
done(); | ||
it('6.2.8 Set the Access-Control-Max-Age header if a max age is provided', function(done) { | ||
var server = test.corsServer({ | ||
preflightMaxAge: 5, | ||
origins: ['http://api.myapp.com', 'http://www.myapp.com'] | ||
}); | ||
request(server) | ||
.options('/test') | ||
.set('Origin', 'http://api.myapp.com') | ||
.set('Access-Control-Request-Method', 'GET') | ||
.expect('Access-Control-Max-Age', '5') | ||
.expect(204) | ||
.end(done); | ||
}); | ||
@@ -91,0 +101,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12655
310
25