0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 16:22:44 +00:00

fixes as asked

This commit is contained in:
Víctor Losada Hernández
2024-12-14 23:34:12 +01:00
parent afc92c4545
commit 99f2972079
3 changed files with 15 additions and 25 deletions

View File

@@ -1,22 +1,15 @@
import packageJSON from '../../package.json' with { type: "json" };
import packageJSON from '../../package.json' with { type: 'json' };
export default (req, res, next) => {
const origin = req.get('Origin');
const sameSite = req.get('Host');
export default (req, res, next)=>{
const userVersion = req.get('Homebrewery-Version');
const version = packageJSON.version;
if (origin && origin !== `http://${sameSite}` && origin !== `https://${sameSite}`) {
return next(); // Skip version check if the request is from another site, like naturalcrit.com
}
if(userVersion !== version) {
return res.status(412).send({
message : `Client version ${userVersion} is out of date. Please save your changes elsewhere and refresh to pick up client version ${version}.`
});
}
const userVersion = req.get('Homebrewery-Version');
const version = packageJSON.version;
if (userVersion !== version) {
return res.status(412).send({
message: `Client version ${userVersion} is out of date. Please save your changes elsewhere and refresh to pick up client version ${version}.`
});
}
next();
next();
};