add dev only things
This commit is contained in:
committed by
Daniel Hutzel
parent
fdd2a7a2c5
commit
29fb47f2e9
@@ -2,28 +2,28 @@ const cds = require("@sap/cds");
|
|||||||
|
|
||||||
// handle bootstrapping events...
|
// handle bootstrapping events...
|
||||||
cds.on("bootstrap", (app) => {
|
cds.on("bootstrap", (app) => {
|
||||||
// dev only
|
if (cds.env.env === "development") {
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
res.header("Access-Control-Allow-Origin", "*");
|
res.header("Access-Control-Allow-Origin", "*");
|
||||||
res.header(
|
res.header(
|
||||||
"Access-Control-Allow-Methods",
|
"Access-Control-Allow-Methods",
|
||||||
"GET, PUT, PATCH, POST, DELETE, OPTIONS"
|
"GET, PUT, PATCH, POST, DELETE, OPTIONS"
|
||||||
);
|
);
|
||||||
res.header(
|
res.header(
|
||||||
"Access-Control-Allow-Headers",
|
"Access-Control-Allow-Headers",
|
||||||
"Origin, X-Requested-With, Content-Type, Accept, Authorization, Accept-Language"
|
"Origin, X-Requested-With, Content-Type, Accept, Authorization, Accept-Language"
|
||||||
);
|
);
|
||||||
|
|
||||||
//intercepts OPTIONS method
|
//intercepts OPTIONS method
|
||||||
if ("OPTIONS" === req.method) {
|
if ("OPTIONS" === req.method) {
|
||||||
//respond with 200
|
//respond with 200
|
||||||
res.sendStatus(200);
|
res.sendStatus(200);
|
||||||
} else {
|
} else {
|
||||||
//move on
|
//move on
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// add your own middleware before any by cds are added
|
}
|
||||||
});
|
});
|
||||||
cds.on("served", async ({ db, messaging, ...servedServices }) => {
|
cds.on("served", async ({ db, messaging, ...servedServices }) => {
|
||||||
// add logging current user before any request
|
// add logging current user before any request
|
||||||
|
|||||||
Reference in New Issue
Block a user