chatboxai/chatbox · warning · Error
Not found
Error message
Not found
What it means
Thrown by resolveRequestPath in the sandbox preview server when the request URL does not start with '/sandbox/' AND no usable relative directory can be derived from the Referer header. The referer-based fallback exists so relative links inside an already-served HTML artifact can resolve sibling assets; without a Referer there is no anchor to resolve against.
Source
Thrown at src/main/sandbox/preview-server.ts:108
return null
}
}
async function resolveRequestPath(
req: IncomingMessage,
sandboxRoots: string[]
): Promise<{
relativePath: string
resolvedPath: string
}> {
const url = new URL(req.url || '/', 'http://127.0.0.1')
let relativePath: string
if (url.pathname.startsWith('/sandbox/')) {
relativePath = decodeUrlPath(url.pathname.slice('/sandbox/'.length))
} else {
const refererDir = getRefererRelativeDir(req)
if (!refererDir) throw new Error('Not found')
relativePath = path.join(refererDir, decodeUrlPath(url.pathname))
}
// The relative path is resolved against each root; the first match that stays inside
// its root and exists wins. Single self-contained artifacts resolve unambiguously.
for (const sandboxRoot of sandboxRoots) {
const targetPath = path.resolve(sandboxRoot, relativePath)
try {
const resolvedPath = await realpath(targetPath)
if (isInside(sandboxRoot, resolvedPath)) {
return { relativePath: path.relative(sandboxRoot, resolvedPath), resolvedPath }
}
} catch {
// Not in this root — try the next.
}
}
throw new Error('Not found')
}View on GitHub (pinned to 81571269ad)
Solutions
- Ensure entry artifacts are served under '/sandbox/<relativePath>' so all assets are requested with '/sandbox/' prefixes and never need the Referer fallback.
- If you must use relative URLs, make sure the HTML document itself was loaded through the preview server (so the browser sends a sandbox Referer).
- Avoid referrerpolicy='no-referrer' / strict Referrer-Policy on sandboxed preview documents.
- Return a 404 response instead of throwing where the caller already wraps in try/catch and maps to 404 (see [85]).
Example fix
// before
const refererDir = getRefererRelativeDir(req)
if (!refererDir) throw new Error('Not found')
// after: also accept an explicit base query param as a fallback
const refererDir = getRefererRelativeDir(req) || url.searchParams.get('base')
if (!refererDir) throw new Error('Not found') Defensive patterns
Strategy: validation
Validate before calling
const url = new URL(req.url || '/', 'http://127.0.0.1')
if (!url.pathname.startsWith('/sandbox/') && !req.headers.referer) { return send404(res) } Type guard
function isPreviewNotFound(e: unknown): e is Error { return e instanceof Error && e.message === 'Not found' } Try / catch
// handleRequest already maps thrown 'Not found' to 404; no extra catch needed at resolveRequestPath level.
Prevention
- Serve entry artifacts under '/sandbox/' so assets inherit that prefix.
- Avoid referrerpolicy='no-referrer' on sandboxed documents.
- Load the HTML document itself through the preview server to ensure a sandbox Referer.
When it happens
Trigger: A GET whose pathname is relative (e.g. '/style.css' or '/assets/x.js') and either has no Referer header, or getRefererRelativeDir(req) returned null/empty because the Referer did not map to a known sandbox path.
Common situations: Opening an asset URL directly in a browser (no Referer); a browser that strips Referer (strict Referrer-Policy, privacy extension); an <img>/<link> whose referrerpolicy='no-referrer'; serving an entry HTML at the wrong URL so its subsequent relative requests lack a matching Referer.
Related errors
- Failed to start preview server
- Offset ${startLine} is beyond end of file (${totalLines} lin
- Not found: ${url}
- GitHub API rate limit exceeded. Try again later.
- Knowledge base name cannot be empty
AI-assisted analysis of chatboxai/chatbox@81571269ad (2026-08-12).
Data as JSON: /api/errors/d1411632f0c5aa21.
Report an issue: GitHub.