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.

feat(wk): wildcard CORS on public discovery + local dev harness

nirholas90252ba195db
diff --git a/api/wk.js b/api/wk.js
index 8acfbdaac..c0fd9b9b3 100644
--- a/api/wk.js
+++ b/api/wk.js
@@ -185,10 +185,23 @@ const DISPATCH = {
'x402-discovery': handleX402Discovery,
};
+// Public discovery docs (x402, x402-discovery, chat-plugin, agent-attestation-schemas)
+// must be readable cross-origin so browser-based validators (agentic.market,
+// x402scan, bazaar) can fetch them. OAuth metadata stays restricted.
+const PUBLIC_DISCOVERY = new Set([
+ 'x402',
+ 'x402-discovery',
+ 'chat-plugin',
+ 'agent-attestation-schemas',
+]);
+
export default wrap(async (req, res) => {
- if (cors(req, res, { methods: 'GET,OPTIONS' })) return;
- if (!method(req, res, ['GET'])) return;
const name = req.query?.name ?? new URL(req.url, 'http://x').searchParams.get('name');
+ const corsOpts = PUBLIC_DISCOVERY.has(name)
+ ? { methods: 'GET,OPTIONS', origins: '*' }
+ : { methods: 'GET,OPTIONS' };
+ if (cors(req, res, corsOpts)) return;
+ if (!method(req, res, ['GET'])) return;
const fn = DISPATCH[name];
if (!fn) return error(res, 404, 'not_found', `unknown well-known resource: ${name}`);
return fn(req, res);
diff --git a/scripts/dev-wk-server.mjs b/scripts/dev-wk-server.mjs
new file mode 100644
index 000000000..cffa31fbf
--- /dev/null
+++ b/scripts/dev-wk-server.mjs
@@ -0,0 +1,38 @@
+#!/usr/bin/env node
+// Local dev server for /.well-known/* handlers — runs the api/wk.js Vercel
+// function under plain Node so we can exercise it without `vercel dev`.
+// Usage: node scripts/dev-wk-server.mjs → http://localhost:3030/.well-known/x402.json
+
+import { createServer } from 'node:http';
+import { config as dotenv } from 'dotenv';
+dotenv({ path: new URL('../.env', import.meta.url) });
+const { default: wkHandler } = await import('../api/wk.js');
+
+const PORT = Number(process.env.PORT || 3030);
+
+const ROUTES = {
+ '/.well-known/x402.json': 'x402-discovery',
+ '/.well-known/x402': 'x402',
+ '/.well-known/chat-plugin.json': 'chat-plugin',
+ '/.well-known/agent-attestation-schemas': 'agent-attestation-schemas',
+ '/.well-known/oauth-authorization-server': 'oauth-authorization-server',
+ '/.well-known/oauth-protected-resource': 'oauth-protected-resource',
+};
+
+const server = createServer(async (req, res) => {
+ const url = new URL(req.url, `http://${req.headers.host || 'localhost'}`);
+ const name = ROUTES[url.pathname];
+ if (!name) {
+ res.statusCode = 404;
+ res.setHeader('content-type', 'application/json');
+ res.end(JSON.stringify({ error: 'not_found', path: url.pathname, known: Object.keys(ROUTES) }));
+ return;
+ }
+ req.query = { name };
+ await wkHandler(req, res);
+});
+
+server.listen(PORT, () => {
+ console.log(`[dev-wk-server] listening on http://localhost:${PORT}`);
+ for (const path of Object.keys(ROUTES)) console.log(` → http://localhost:${PORT}${path}`);
+});