Added CORS middleware. Updated umami script.
This commit is contained in:
20
lib/middleware.js
Normal file
20
lib/middleware.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import cors from 'cors';
|
||||
|
||||
export function use(middleware) {
|
||||
return (req, res) =>
|
||||
new Promise((resolve, reject) => {
|
||||
middleware(req, res, result => {
|
||||
if (result instanceof Error) {
|
||||
return reject(result);
|
||||
}
|
||||
return resolve(result);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export const allowPost = use(
|
||||
cors({
|
||||
origin: '*',
|
||||
methods: ['POST', 'OPTIONS'],
|
||||
}),
|
||||
);
|
||||
Reference in New Issue
Block a user