Hide domain matching behind a feature flag
This commit is contained in:
parent
3303b70fa4
commit
14bb35d1bb
@ -24,6 +24,9 @@ export const MAILCATCHER_API_PORT = parseInt(
|
||||
export const MAILER = process.env.SEALIOUS_MAILER || "mailcatcher";
|
||||
export const DEFAULT_HTML_LANG = "pl";
|
||||
|
||||
// if enabled, domain name will be checked when matching cusom pages from DB by URL. Otherwise only the path part of the URL is used
|
||||
export const MULTI_DOMAIN_ENABLED = process.env.MULTI_DOMAIN_ENABLED == "true" || false;
|
||||
|
||||
export const IMAGE_CACHE_FS_DIR =
|
||||
process.env.IMAGE_CACHE_FS_DIR || locreq.resolve("cache/images");
|
||||
export const SMARTCROP_CACHE_FS_DIR =
|
||||
|
@ -10,7 +10,7 @@ import type { FilePointer } from "@sealcode/file-manager";
|
||||
import html from "../../html.js";
|
||||
import { tempstream } from "tempstream";
|
||||
import { defaultHead } from "../../defaultHead.js";
|
||||
import { BASE_URL } from "../../config.js";
|
||||
import { BASE_URL, MULTI_DOMAIN_ENABLED } from "../../config.js";
|
||||
|
||||
interface ContextState {
|
||||
jddNames: string[];
|
||||
@ -23,17 +23,22 @@ export const customUrlView =
|
||||
if (ctx.body) return;
|
||||
const main_domain = new URL(BASE_URL).hostname;
|
||||
|
||||
const {
|
||||
items: [page],
|
||||
} = await app.collections.pages
|
||||
.list(ctx.$context)
|
||||
.filter({
|
||||
url: ctx.url.split("?")[0],
|
||||
let filter = {
|
||||
url: ctx.url.split("?")[0],
|
||||
};
|
||||
|
||||
if (MULTI_DOMAIN_ENABLED) {
|
||||
filter = {
|
||||
...filter,
|
||||
...(ctx.hostname !== main_domain
|
||||
? { domain: ctx.hostname }
|
||||
: { domain: "" }),
|
||||
})
|
||||
.fetch();
|
||||
};
|
||||
}
|
||||
|
||||
const {
|
||||
items: [page],
|
||||
} = await app.collections.pages.list(ctx.$context).filter(filter).fetch();
|
||||
|
||||
const pageContent = Array.isArray(page?.get("content"))
|
||||
? (page?.get("content") as RawJDDocument)
|
||||
|
Loading…
x
Reference in New Issue
Block a user