Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(embed): serve the UMD bundle as JavaScript and stop caching 404s on unreleased versions for a year

nirholas729807b9a68c
diff --git a/server/index.mjs b/server/index.mjs
index 148c6a6b5..dbc74a852 100644
--- a/server/index.mjs
+++ b/server/index.mjs
@@ -294,6 +294,11 @@ function serveFile(req, res, file, headers, status) {
}
res.set(headers);
if (status) res.status(status);
+ // The mime table maps .cjs to application/node, and with nosniff a browser
+ // refuses to execute that from a <script> tag, so the documented UMD embed
+ // (/agent-3d/<v>/agent-3d.umd.cjs) silently never ran. send() keeps a
+ // content-type that is already set.
+ if (file.endsWith('.cjs')) res.type('text/javascript');
// Android Digital Asset Links (and the other RFC 8615 discovery files) are
// re-fetched by Google and by devices on a schedule; a day-long edge TTL
// means a rotated release key stays unverified for up to 24 hours after a
@@ -575,7 +580,13 @@ app.use(async (req, res) => {
}
}
- // Post-filesystem rules (the 404.html fallback).
+ // Post-filesystem rules (the 404.html fallback). A cache policy collected in
+ // phase 1 described the file that rule expected to find, not this miss:
+ // /agent-3d/<unreleased version>/ inherited `max-age=31536000, immutable`,
+ // and the CDN then held that 404 for a year after the version was cut.
+ for (const key of Object.keys(collected)) {
+ if (key.toLowerCase() === 'cache-control') delete collected[key];
+ }
for (const route of postFsRoutes) {
const m = route.re.exec(currentPath);
if (!m) continue;
diff --git a/tests/server-agent-3d-headers.test.js b/tests/server-agent-3d-headers.test.js
new file mode 100644
index 000000000..71ea121e9
--- /dev/null
+++ b/tests/server-agent-3d-headers.test.js
@@ -0,0 +1,52 @@
+import { describe, it, expect, beforeAll, afterAll } from 'vitest';
+import { startTestServer } from './helpers/test-server.js';
+import { existsSync } from 'node:fs';
+import { fileURLToPath } from 'node:url';
+
+// Two header faults on the versioned embed routes, both measured live on
+// 2026-10-08:
+//
+// GET /agent-3d/1.5.2/agent-3d.umd.cjs -> content-type: application/node
+// With nosniff, a browser refuses to run that from a <script> tag, so the
+// UMD embed documented in docs/web-component.md never executed.
+//
+// GET /agent-3d/1.5.3/ (not released) -> 404 with max-age=31536000, immutable
+// The versioned rule's cache policy carried into the 404 fallback, so the
+// CDN would keep answering 404 for a year after the version was cut.
+
+// publish:lib writes dist/agent-3d/; without it there is nothing to serve.
+const HAS_LIB = existsSync(fileURLToPath(new URL('../dist/agent-3d/versions.json', import.meta.url)));
+if (!HAS_LIB) console.warn('[server-agent-3d-headers] skipping: dist/agent-3d/ is missing. Run `npm run publish:lib`.');
+
+let BASE;
+let server;
+
+beforeAll(async () => {
+ if (!HAS_LIB) return;
+ server = await startTestServer();
+ BASE = server.base;
+}, 30000);
+
+afterAll(() => {
+ server?.close();
+});
+
+describe.skipIf(!HAS_LIB)('agent-3d versioned route headers', () => {
+ it('serves the UMD build as JavaScript a script tag will execute', async (ctx) => {
+ const versions = await (await fetch(`${BASE}/agent-3d/versions.json`)).json().catch(() => null);
+ const pinned = Object.entries(versions?.channels || {}).find(([, c]) => c?.immutable)?.[0];
+ if (!pinned) ctx.skip();
+ const res = await fetch(`${BASE}/agent-3d/${pinned}/agent-3d.umd.cjs`);
+ if (res.status === 404) ctx.skip();
+ expect(res.status).toBe(200);
+ expect(res.headers.get('content-type')).toMatch(/^text\/javascript/);
+ expect(res.headers.get('cache-control')).toContain('immutable');
+ });
+
+ it('never marks a miss on an unreleased version immutable', async () => {
+ const res = await fetch(`${BASE}/agent-3d/999.999.999/agent-3d.js`);
+ expect(res.status).toBe(404);
+ expect(res.headers.get('cache-control') || '').not.toContain('immutable');
+ expect(res.headers.get('cache-control') || '').not.toContain('31536000');
+ });
+});