@tinyhttp/cors
Advanced tools
Comparing version 1.3.1 to 1.3.2
@@ -7,4 +7,5 @@ import { vary } from 'es-vary'; | ||
const cors = (opts = {}) => { | ||
const { origin = '*', methods = ['GET', 'HEAD', 'PUT', 'PATCH', 'POST', 'DELETE'], allowedHeaders, exposedHeaders, credentials, maxAge, optionsSuccessStatus = 204, preflightContinue = false } = opts; | ||
const { origin = '*', methods = ['GET', 'HEAD', 'PUT', 'PATCH', 'POST', 'DELETE'], allowedHeaders = ['content-type'], exposedHeaders, credentials, maxAge, optionsSuccessStatus = 204, preflightContinue = false } = opts; | ||
return (req, res, next) => { | ||
var _a, _b; | ||
// Checking the type of the origin property | ||
@@ -47,5 +48,5 @@ if (typeof origin === 'boolean' && origin === true) { | ||
res.setHeader('Access-Control-Max-Age', maxAge); | ||
if (req.method?.toUpperCase?.() === 'OPTIONS') { | ||
if (((_b = (_a = req.method) === null || _a === void 0 ? void 0 : _a.toUpperCase) === null || _b === void 0 ? void 0 : _b.call(_a)) === 'OPTIONS') { | ||
if (preflightContinue) { | ||
next?.(); | ||
next === null || next === void 0 ? void 0 : next(); | ||
} | ||
@@ -59,3 +60,3 @@ else { | ||
else { | ||
next?.(); | ||
next === null || next === void 0 ? void 0 : next(); | ||
} | ||
@@ -62,0 +63,0 @@ }; |
{ | ||
"name": "@tinyhttp/cors", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "tinyhttp CORS module", | ||
@@ -5,0 +5,0 @@ "type": "module", |
10996
6
140