24 lines
649 B
JavaScript
24 lines
649 B
JavaScript
import cors from 'cors';
|
|
|
|
// And to throw an error when an error happens in a middleware
|
|
|
|
function initMiddleware(middleware) {
|
|
return function (req, res, options) {
|
|
return new Promise(function (resolve, reject) {
|
|
middleware(options)(req, res, function (result) {
|
|
if (result instanceof Error) {
|
|
return reject(result);
|
|
}
|
|
|
|
return resolve(result);
|
|
});
|
|
});
|
|
};
|
|
} // You can read more about the available options here: https://github.com/expressjs/cors#configuration-options
|
|
|
|
|
|
var NextCors = /*#__PURE__*/initMiddleware(cors);
|
|
|
|
export default NextCors;
|
|
//# sourceMappingURL=nextjs-cors.esm.js.map
|