Serve CMS at root and bootstrap Authentik in compose

This commit is contained in:
DCCONSTRUCTIONS
2026-07-06 10:32:24 +03:00
parent 5004627476
commit 4b4963101a
6 changed files with 72 additions and 29 deletions
+10 -10
View File
@@ -330,9 +330,9 @@ function callbackUri(req) {
function sanitizeReturnTo(value) {
const rawValue = String(value || "").trim();
if (!rawValue || rawValue.startsWith("//")) return "/admin/";
if (/^https?:\/\//i.test(rawValue)) return "/admin/";
return rawValue.startsWith("/") ? rawValue : "/admin/";
if (!rawValue || rawValue.startsWith("//")) return "/";
if (/^https?:\/\//i.test(rawValue)) return "/";
return rawValue.startsWith("/") ? rawValue : "/";
}
function sendRedirect(res, target, status = 302) {
@@ -710,7 +710,7 @@ async function handleAuthRoute(req, res, url) {
}
if (req.method === "GET" && url.pathname === "/auth/logged-out") {
sendRedirect(res, authLoginUrl(req, "/admin/"));
sendRedirect(res, authLoginUrl(req, "/"));
return true;
}
@@ -2026,11 +2026,12 @@ function parseMultipartUpload(req, bodyBuffer) {
function safePublicPath(urlPath) {
const withoutQuery = decodeURIComponent(urlPath.split("?")[0]);
const adminRootFiles = new Set(["/admin.css", "/admin.js", "/nodedc-logo.svg"]);
const requestPath =
withoutQuery === "/"
? "/index.html"
: withoutQuery === "/admin" || withoutQuery === "/admin/"
? "/admin/index.html"
withoutQuery === "/" || withoutQuery === "/admin" || withoutQuery === "/admin/"
? "/admin/index.html"
: adminRootFiles.has(withoutQuery)
? `/admin${withoutQuery}`
: withoutQuery;
const normalized = normalize(requestPath).replace(/^(\.\.[/\\])+/, "");
const isAdminAsset = normalized === "/admin/index.html" || normalized.startsWith("/admin/");
@@ -2283,7 +2284,6 @@ const server = createServer(async (req, res) => {
});
server.listen(port, host, () => {
console.log(`DC CMS admin: http://${host}:${port}/admin/`);
console.log(`Project site: http://${host}:${port}/`);
console.log(`DC CMS: http://${host}:${port}/`);
console.log(`Project root: ${repoRoot}`);
});