Files
clawhub/src/lib/docsAuth.ts
T
Patrick Erichsen fdb4d312f4 docs: restore OpenClaw-hosted ClawHub docs (#2631)
* Revert "fix: serve docs subdomain root (#2630)"

This reverts commit 9ef33726b8.

* Revert "feat: move docs to canonical subdomain"

This reverts commit 6afb91b772.

* Revert "docs: serve ClawHub docs with shared OpenClaw renderer (#2609)"

This reverts commit 71156751ff.

* fix: restore ClawHub email docs host

* test: preserve non-docs validation fixes

* test: remove stale docs proxy test

* docs: keep ClawHub contributor references current

* fix: keep docs auth callback outside docs routes
2026-06-14 16:05:34 -07:00

26 lines
710 B
TypeScript

const allowedDocsOrigins = new Set([
"https://documentation.openclaw.ai",
"https://docs.openclaw.ai",
"http://localhost:4173",
"http://127.0.0.1:4173",
]);
export function normalizeDocsReturnTo(value?: string | null) {
if (!value) return null;
try {
const url = new URL(value);
if (!allowedDocsOrigins.has(url.origin)) return null;
if (!["http:", "https:"].includes(url.protocol)) return null;
return url.href;
} catch {
return null;
}
}
export function buildDocsAuthCallbackUrl(returnTo: string) {
const normalized = normalizeDocsReturnTo(returnTo);
if (!normalized) return null;
const url = new URL(normalized);
return `${url.origin}/ask-molty/auth/callback`;
}