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 MAILER = process.env.SEALIOUS_MAILER || "mailcatcher";
|
||||||
export const DEFAULT_HTML_LANG = "pl";
|
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 =
|
export const IMAGE_CACHE_FS_DIR =
|
||||||
process.env.IMAGE_CACHE_FS_DIR || locreq.resolve("cache/images");
|
process.env.IMAGE_CACHE_FS_DIR || locreq.resolve("cache/images");
|
||||||
export const SMARTCROP_CACHE_FS_DIR =
|
export const SMARTCROP_CACHE_FS_DIR =
|
||||||
|
@ -10,7 +10,7 @@ import type { FilePointer } from "@sealcode/file-manager";
|
|||||||
import html from "../../html.js";
|
import html from "../../html.js";
|
||||||
import { tempstream } from "tempstream";
|
import { tempstream } from "tempstream";
|
||||||
import { defaultHead } from "../../defaultHead.js";
|
import { defaultHead } from "../../defaultHead.js";
|
||||||
import { BASE_URL } from "../../config.js";
|
import { BASE_URL, MULTI_DOMAIN_ENABLED } from "../../config.js";
|
||||||
|
|
||||||
interface ContextState {
|
interface ContextState {
|
||||||
jddNames: string[];
|
jddNames: string[];
|
||||||
@ -23,17 +23,22 @@ export const customUrlView =
|
|||||||
if (ctx.body) return;
|
if (ctx.body) return;
|
||||||
const main_domain = new URL(BASE_URL).hostname;
|
const main_domain = new URL(BASE_URL).hostname;
|
||||||
|
|
||||||
const {
|
let filter = {
|
||||||
items: [page],
|
url: ctx.url.split("?")[0],
|
||||||
} = await app.collections.pages
|
};
|
||||||
.list(ctx.$context)
|
|
||||||
.filter({
|
if (MULTI_DOMAIN_ENABLED) {
|
||||||
url: ctx.url.split("?")[0],
|
filter = {
|
||||||
|
...filter,
|
||||||
...(ctx.hostname !== main_domain
|
...(ctx.hostname !== main_domain
|
||||||
? { domain: ctx.hostname }
|
? { domain: ctx.hostname }
|
||||||
: { domain: "" }),
|
: { domain: "" }),
|
||||||
})
|
};
|
||||||
.fetch();
|
}
|
||||||
|
|
||||||
|
const {
|
||||||
|
items: [page],
|
||||||
|
} = await app.collections.pages.list(ctx.$context).filter(filter).fetch();
|
||||||
|
|
||||||
const pageContent = Array.isArray(page?.get("content"))
|
const pageContent = Array.isArray(page?.get("content"))
|
||||||
? (page?.get("content") as RawJDDocument)
|
? (page?.get("content") as RawJDDocument)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user