ghost 4.48.6 → 4.48.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -53,4 +53,22 @@ function corsOptionsDelegate(req, callback) {
|
|
|
53
53
|
callback(null, corsOptions);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
/**
|
|
57
|
+
*
|
|
58
|
+
* @param {Express.Request} req
|
|
59
|
+
* @param {Express.Response} res
|
|
60
|
+
* @param {Function} next
|
|
61
|
+
*/
|
|
62
|
+
const handleCaching = (req, res, next) => {
|
|
63
|
+
const method = req.method && req.method.toUpperCase && req.method.toUpperCase();
|
|
64
|
+
if (method === 'OPTIONS') {
|
|
65
|
+
// @NOTE: try to add native support for dynamic 'vary' header value in 'cors' module
|
|
66
|
+
res.vary('Origin');
|
|
67
|
+
}
|
|
68
|
+
next();
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
module.exports = [
|
|
72
|
+
handleCaching,
|
|
73
|
+
cors(corsOptionsDelegate)
|
|
74
|
+
];
|
|
@@ -64,7 +64,7 @@ function getAllowlist() {
|
|
|
64
64
|
* @param {Function} cb callback that configures CORS.
|
|
65
65
|
* @return {null}
|
|
66
66
|
*/
|
|
67
|
-
function
|
|
67
|
+
function corsOptionsDelegate(req, cb) {
|
|
68
68
|
const origin = req.get('origin');
|
|
69
69
|
|
|
70
70
|
// Request must have an Origin header
|
|
@@ -80,4 +80,22 @@ function handleCORS(req, cb) {
|
|
|
80
80
|
return cb(null, DISABLE_CORS);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
/**
|
|
84
|
+
*
|
|
85
|
+
* @param {Express.Request} req
|
|
86
|
+
* @param {Express.Response} res
|
|
87
|
+
* @param {Function} next
|
|
88
|
+
*/
|
|
89
|
+
const handleCaching = (req, res, next) => {
|
|
90
|
+
const method = req.method && req.method.toUpperCase && req.method.toUpperCase();
|
|
91
|
+
if (method === 'OPTIONS') {
|
|
92
|
+
// @NOTE: try to add native support for dynamic 'vary' header value in 'cors' module
|
|
93
|
+
res.vary('Origin');
|
|
94
|
+
}
|
|
95
|
+
next();
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
module.exports = [
|
|
99
|
+
handleCaching,
|
|
100
|
+
cors(corsOptionsDelegate)
|
|
101
|
+
];
|