mirror of
https://github.com/umami-software/umami.git
synced 2025-12-08 05:12:36 +01:00
Added CORS middleware. Updated umami script.
This commit is contained in:
parent
bb04015b46
commit
58a1c63407
10 changed files with 144 additions and 78 deletions
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'],
|
||||
}),
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue