qumra-engine 2.0.67 → 2.0.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -7,7 +7,6 @@ exports.prepareDataMiddleware = void 0;
|
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const prepareDataMiddleware = (req, res, next) => {
|
|
9
9
|
const parsedUrl = res.locals.parsedUrl;
|
|
10
|
-
console.log("🚀 ~ prepareDataMiddleware ~ parsedUrl:", parsedUrl);
|
|
11
10
|
// ✅ تخطي الرندر في production لبعض المسارات
|
|
12
11
|
// if (res.locals.mode === "production") {
|
|
13
12
|
// if (isPathAllowedToRender(parsedUrl.pathname)) {
|
|
@@ -54,15 +53,23 @@ const prepareDataMiddleware = (req, res, next) => {
|
|
|
54
53
|
// axios لا يستخدم .ok ولا .json()
|
|
55
54
|
// البيانات موجودة مباشرة في engineResponse.data
|
|
56
55
|
const data = engineResponse.data?.data;
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
if (!res.locals.isIframe) {
|
|
57
|
+
const backendUrl = data.globals?.app?.url;
|
|
58
|
+
const expectedHost = typeof backendUrl === "string"
|
|
59
|
+
? new URL(backendUrl).host
|
|
60
|
+
: backendUrl?.host;
|
|
61
|
+
if (parsedUrl.host !== expectedHost) {
|
|
62
|
+
//redirect to expected host
|
|
63
|
+
return res.redirect(301, `${data.globals?.app?.url}${parsedUrl.pathname}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
59
66
|
res.locals.render = engineResponse.data?.data;
|
|
60
67
|
next();
|
|
61
68
|
})
|
|
62
69
|
.catch((err) => {
|
|
63
70
|
console.log("🚀 ~ prepareDataMiddleware ~ err:", err);
|
|
64
71
|
console.log("❌ prepareDataMiddleware error:", err.message);
|
|
65
|
-
|
|
72
|
+
next(err);
|
|
66
73
|
});
|
|
67
74
|
};
|
|
68
75
|
exports.prepareDataMiddleware = prepareDataMiddleware;
|
package/dist/middleware.js
CHANGED
|
@@ -27,6 +27,7 @@ const startEngine = async ({ mode, getRender, setRender, port = 3000, themesRepo
|
|
|
27
27
|
app.use((0, cookie_parser_1.default)());
|
|
28
28
|
app.set("view engine", "nunjucks");
|
|
29
29
|
app.use((0, morgan_1.default)("dev"));
|
|
30
|
+
app.use("health", (req, res) => res.send("OK"));
|
|
30
31
|
app.use((req, res, next) => {
|
|
31
32
|
const isIframe = req.query.iframe === "1" || req.headers["sec-fetch-dest"] === "iframe";
|
|
32
33
|
if (isIframe) {
|