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(api): stop 500ing cross-origin reads that passed a 'same' sentinel to cors()

nirholas30337f3bafef
diff --git a/api/irl/analytics.js b/api/irl/analytics.js
index dbdc5bafd..e9448b085 100644
--- a/api/irl/analytics.js
+++ b/api/irl/analytics.js
@@ -14,7 +14,12 @@ import { authorizeOps } from '../_lib/ops-auth.js';
import { getIrlAnalyticsSummary } from '../_lib/irl-analytics.js';
export default wrap(async (req, res) => {
- if (cors(req, res, { methods: 'GET,OPTIONS', origins: 'same' })) return;
+ // Omitting `origins` IS the same-origin policy: cors() then falls back to the
+ // first-party allow-list in isAllowedOrigin(). Passing a sentinel string instead
+ // (`origins: 'same'`) reached `allowed.some(...)` on a string and threw, so every
+ // request carrying an Origin header - including the browser's preflight - came
+ // back 500 rather than a CORS decision.
+ if (cors(req, res, { methods: 'GET,OPTIONS' })) return;
if (req.method?.toUpperCase() !== 'GET') return error(res, 405, 'method_not_allowed', 'GET only');
const rl = await limits.authIp(clientIp(req));
diff --git a/api/ops/health.js b/api/ops/health.js
index ddc102057..a129925cd 100644
--- a/api/ops/health.js
+++ b/api/ops/health.js
@@ -103,7 +103,11 @@ async function runProbe(probe) {
}
export default wrap(async (req, res) => {
- if (cors(req, res, { methods: 'GET,OPTIONS', origins: 'same' })) return;
+ // Same-origin is what cors() does when `origins` is omitted (it falls back to the
+ // first-party allow-list). A sentinel string was not a supported value: it reached
+ // `allowed.some(...)` and threw, 500ing any request that carried an Origin header,
+ // preflights included. Same fix as api/irl/analytics.js.
+ if (cors(req, res, { methods: 'GET,OPTIONS' })) return;
if (req.method?.toUpperCase() !== 'GET') return error(res, 405, 'method_not_allowed', 'GET only');
const rl = await limits.authIp(clientIp(req));