fix: the trust proxy setting
This commit is contained in:
@@ -458,14 +458,13 @@ module.exports.addCategory = [
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const ext = extname(image.name)
|
const ext = extname(image.name);
|
||||||
const imageName = `shafafiat_icon_${Date.now()}_${targetCategory._id}.${ext}`;
|
const imageName = `shafafiat_icon_${Date.now()}${ext}`;
|
||||||
try {
|
try {
|
||||||
await image.mv(
|
await image.mv(
|
||||||
`${process.cwd()}/static/uploads/images/category/shafafiat/${imageName}`
|
`${process.cwd()}/static/uploads/images/category/shafafiat/${imageName}`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* if exist old pic delete it from file
|
* if exist old pic delete it from file
|
||||||
*/
|
*/
|
||||||
@@ -691,9 +690,7 @@ module.exports.updateCategory = [
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (checkDuppTitle) {
|
if (checkDuppTitle) {
|
||||||
return res
|
return res.status(422).json({
|
||||||
.status(422)
|
|
||||||
.json({
|
|
||||||
validation: { title: { msg: _sr["fa"].duplicated.title } },
|
validation: { title: { msg: _sr["fa"].duplicated.title } },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -852,8 +849,8 @@ module.exports.updateCategory = [
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const ext = extname(image.name)
|
const ext = extname(image.name);
|
||||||
const imageName = `shafafiat_icon_${Date.now()}_${targetCategory._id}.${ext}`;
|
const imageName = `shafafiat_icon_${Date.now()}${ext}`;
|
||||||
try {
|
try {
|
||||||
await image.mv(
|
await image.mv(
|
||||||
`${process.cwd()}/static/uploads/images/category/shafafiat/${imageName}`
|
`${process.cwd()}/static/uploads/images/category/shafafiat/${imageName}`
|
||||||
|
|||||||
@@ -262,6 +262,7 @@ module.exports.verifyOtp = [
|
|||||||
|
|
||||||
// Create or update login logger
|
// Create or update login logger
|
||||||
const logger = await Logger.findOne({ user: user._id });
|
const logger = await Logger.findOne({ user: user._id });
|
||||||
|
console.log("admin logged in", req.ip);
|
||||||
if (logger) {
|
if (logger) {
|
||||||
await Logger.findOneAndUpdate(
|
await Logger.findOneAndUpdate(
|
||||||
{ user: user._id },
|
{ user: user._id },
|
||||||
|
|||||||
+6
-1
@@ -26,7 +26,12 @@ for (const item of portals) {
|
|||||||
// Create express instance
|
// Create express instance
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
app.set("trust proxy", 1);
|
app.set("trust proxy", true);
|
||||||
|
app.use((req, res, next) => {
|
||||||
|
console.log(req.ip);
|
||||||
|
console.log(req.ips);
|
||||||
|
next();
|
||||||
|
});
|
||||||
app.disable("x-powered-by");
|
app.disable("x-powered-by");
|
||||||
|
|
||||||
app.use(morgan("combined"));
|
app.use(morgan("combined"));
|
||||||
|
|||||||
Reference in New Issue
Block a user