dev: fix ALLOWED_HOSTS quoting in content-edit-storage.js

This commit is contained in:
Bot Dev committed 2026-07-29 19:06:35 +02:00
1 parent e42f0c746c
commit 3b706066c9
1 file changed
+29 -28
@@ -1,28 +1,29 @@
const API = "/api/content-edits";
export function getPagePath() {
const path = window.location.pathname.replace(/^\//, "");
if (!path || path.endsWith("/")) return "index.html";
return path;
}
export async function loadEdits(page = getPagePath()) {
const res = await fetch(`${API}?page=${encodeURIComponent(page)}`);
if (!res.ok) throw new Error("load failed");
return res.json();
}
export async function saveEdits(payload) {
const res = await fetch(`${API}?page=${encodeURIComponent(payload.page)}`, {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload),
});
if (!res.ok) throw new Error("save failed");
return res.json();
}
export function isContentEditHost() {
const host = window.location.hostname;
const ALLOWED_HOSTS = [localhost, 127.0.0.1, dev.mamadaevv.site, f2ogw6fzi6trnp7cp43x8wsd.31.129.103.242.sslip.io];\n return ALLOWED_HOSTS.includes(host);
}
const API = "/api/content-edits";
export function getPagePath() {
const path = window.location.pathname.replace(/^\//, "");
if (!path || path.endsWith("/")) return "index.html";
return path;
}
export async function loadEdits(page = getPagePath()) {
const res = await fetch(`${API}?page=${encodeURIComponent(page)}`);
if (!res.ok) throw new Error("load failed");
return res.json();
}
export async function saveEdits(payload) {
const res = await fetch(`${API}?page=${encodeURIComponent(payload.page)}`, {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload),
});
if (!res.ok) throw new Error("save failed");
return res.json();
}
export function isContentEditHost() {
const host = window.location.hostname;
const ALLOWED_HOSTS = ["localhost", "127.0.0.1", "dev.mamadaevv.site", "f2ogw6fzi6trnp7cp43x8wsd.31.129.103.242.sslip.io"];
return ALLOWED_HOSTS.includes(host);
}