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(ibm): stop the demo pages CORS-blocking their own payment script off production

nirholasb1f6db3bef9a
diff --git a/pages/ibm/hello.html b/pages/ibm/hello.html
index f03902894..c4a854a2a 100644
--- a/pages/ibm/hello.html
+++ b/pages/ibm/hello.html
@@ -421,13 +421,13 @@ a:focus-visible{outline-offset:3px}
<link rel="canonical" href="https://three.ws/ibm/hello">
<meta property="og:site_name" content="three.ws">
<meta property="og:url" content="https://three.ws/ibm/x402-demo">
- <meta property="og:image" content="https://three.ws/api/page-og?s=crypto&amp;t=IBM+%C3%97+three.ws+partnership&amp;d=The+IBM+%C3%97+three.ws+partnership+page%3A+how+three.ws%27s+agent+identity%2C+x402+payment+rails%2C+and+MCP+servers+integrate+with+IBM+watsonx+and+the+IBM+x402+ecosystem.&amp;p=%2Fibm%2Fhello">
+ <meta property="og:image" content="https://three.ws/api/page-og?s=crypto&amp;t=x402+Live+Demo+%28IBM+%C3%97+three.ws%29&amp;d=A+self-contained+x402+micropayment+demo%3A+pay+%240.001+USDC+from+your+own+wallet+%E2%80%94+MetaMask+on+Base+or+Phantom+on+Solana+%E2%80%94+to+call+a+real+three.ws+data+API.+Watch+&amp;p=%2Fibm%2Fx402-demo">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="x402 Live Demo (IBM × three.ws) · three.ws" data-i18n-attr="content:ibm_hello.meta_twitter_title">
<meta name="twitter:description" content="A self-contained x402 micropayment demo: pay $0.001 USDC from your own wallet — MetaMask on Base or Phantom on Solana — to call a real three.ws data API. Watch the live HTTP 402 challenge, sign a gasless authorization, and see the on-chain settlement receipt. No backend, no account; built as the public face of the IBM × three.ws partnership." data-i18n-attr="content:ibm_hello.meta_twitter_description">
- <meta name="twitter:image" content="https://three.ws/api/page-og?s=crypto&amp;t=IBM+%C3%97+three.ws+partnership&amp;d=The+IBM+%C3%97+three.ws+partnership+page%3A+how+three.ws%27s+agent+identity%2C+x402+payment+rails%2C+and+MCP+servers+integrate+with+IBM+watsonx+and+the+IBM+x402+ecosystem.&amp;p=%2Fibm%2Fhello">
+ <meta name="twitter:image" content="https://three.ws/api/page-og?s=crypto&amp;t=x402+Live+Demo+%28IBM+%C3%97+three.ws%29&amp;d=A+self-contained+x402+micropayment+demo%3A+pay+%240.001+USDC+from+your+own+wallet+%E2%80%94+MetaMask+on+Base+or+Phantom+on+Solana+%E2%80%94+to+call+a+real+three.ws+data+API.+Watch+&amp;p=%2Fibm%2Fx402-demo">
<script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","name":"x402 Live Demo (IBM × three.ws)","description":"A self-contained x402 micropayment demo: pay $0.001 USDC from your own wallet — MetaMask on Base or Phantom on Solana — to call a real three.ws data API. Watch the live HTTP 402 challenge, sign a gasless authorization, and see the on-chain settlement receipt. No backend, no account; built as the public face of the IBM × three.ws partnership.","url":"https://three.ws/ibm/x402-demo","isPartOf":{"@type":"WebSite","name":"three.ws","url":"https://three.ws"}}</script>
<!-- model-viewer renders the GLB returned by the paid Forge demo (Demo 01).
Self-hosted (travels with this file under ./vendor/) so the page needs no
@@ -1462,7 +1462,7 @@ a:focus-visible{outline-offset:3px}
<div class="copy-row"><button class="copy-btn" id="copyBtn" type="button" data-i18n="ibm_hello.copy_snippet">Copy snippet</button></div>
<!-- The snippet above, wired live. x402.js (loaded near <!-- Runtime i18n: detects locale, swaps annotated copy, mounts <lang-switcher>. -->
- <script type="application/ibm-baked" data-ibm-type="module" data-ibm-src="/i18n.js"></script>
+ <script type="application/ibm-baked" data-ibm-type="module" data-ibm-src="https://three.ws/i18n.js"></script>
</body>) binds any
[data-x402-endpoint]; this is the same $THREE Town Oracle the in-world
kiosk on /play buys from, settled in real USDC or $THREE over x402. -->
@@ -1639,7 +1639,12 @@ a:focus-visible{outline-offset:3px}
</div>
</footer>
-<!-- x402 drop-in payment modal (Phantom/MetaMask wallet flow + 402 retry) -->
+<!-- x402 drop-in payment modal (Phantom/MetaMask wallet flow + 402 retry).
+ Same-origin on purpose: the copyable snippet above shows the absolute
+ https://three.ws/x402.js an external embedder needs, but this page ships
+ with the file, and loading its own copy across an origin means every
+ non-production origin (a preview deploy, a local run, an audit sweep)
+ gets the script CORS-blocked and the paid demos below never arm. -->
<script type="application/ibm-baked" data-ibm-type="module" data-ibm-src="https://three.ws/x402.js"></script>
<!-- <agent-3d> web component — the whole 3D agent framework in one tag. Lazy-boots when scrolled into view. -->
<script type="application/ibm-baked" data-ibm-type="module" data-ibm-src="https://three.ws/agent-3d/latest/agent-3d.js"></script>
diff --git a/pages/ibm/hello.live.html b/pages/ibm/hello.live.html
index 0e396d2f7..51a52c34f 100644
--- a/pages/ibm/hello.live.html
+++ b/pages/ibm/hello.live.html
@@ -1627,8 +1627,13 @@ a:focus-visible{outline-offset:3px}
</div>
</footer>
-<!-- x402 drop-in payment modal (Phantom/MetaMask wallet flow + 402 retry) -->
-<script type="module" src="https://three.ws/x402.js"></script>
+<!-- x402 drop-in payment modal (Phantom/MetaMask wallet flow + 402 retry).
+ Same-origin on purpose: the copyable snippet above shows the absolute
+ https://three.ws/x402.js an external embedder needs, but this page ships
+ with the file, and loading its own copy across an origin means every
+ non-production origin (a preview deploy, a local run, an audit sweep)
+ gets the script CORS-blocked and the paid demos below never arm. -->
+<script type="module" src="/x402.js"></script>
<!-- <agent-3d> web component — the whole 3D agent framework in one tag. Lazy-boots when scrolled into view. -->
<script type="module" src="https://three.ws/agent-3d/latest/agent-3d.js"></script>
diff --git a/pages/ibm/x402-demo.html b/pages/ibm/x402-demo.html
index 2e45a0d56..63c250146 100644
--- a/pages/ibm/x402-demo.html
+++ b/pages/ibm/x402-demo.html
@@ -1112,8 +1112,13 @@ agent-3d:defined ~ .agent-skel{display:none}
</div>
</footer>
-<!-- x402 drop-in payment modal (Phantom/MetaMask wallet flow + 402 retry) -->
-<script type="module" src="https://three.ws/x402.js"></script>
+<!-- x402 drop-in payment modal (Phantom/MetaMask wallet flow + 402 retry).
+ Same-origin on purpose: the copyable snippet above shows the absolute
+ https://three.ws/x402.js an external embedder needs, but this page ships
+ with the file, and loading its own copy across an origin means every
+ non-production origin (a preview deploy, a local run, an audit sweep)
+ gets the script CORS-blocked and the paid demos below never arm. -->
+<script type="module" src="/x402.js"></script>
<!-- <agent-3d> web component — the whole 3D agent framework in one tag. Lazy-boots when scrolled into view. -->
<script type="module" src="https://three.ws/agent-3d/latest/agent-3d.js"></script>
diff --git a/scripts/build-ibm-shell.mjs b/scripts/build-ibm-shell.mjs
index b5d1ba266..10dabcc4b 100644
--- a/scripts/build-ibm-shell.mjs
+++ b/scripts/build-ibm-shell.mjs
@@ -30,6 +30,8 @@ const SRC = join(ROOT, 'pages/ibm/hello.live.html');
const OUT = join(ROOT, 'pages/ibm/hello.html');
const LIVE_URL = 'https://three.ws/ibm/hello.live';
+const SITE_ORIGIN = 'https://three.ws';
+
const EXEC_TYPES = new Set(['', 'module', 'text/javascript', 'application/javascript']);
const INERT_TYPE = 'application/ibm-baked';
@@ -38,6 +40,18 @@ function attr(attrs, name) {
return m ? (m[2] ?? m[3] ?? m[4] ?? '') : '';
}
+// The live page loads its own assets same-origin ('/x402.js'), which is what
+// keeps it working on every origin three.ws itself is served from: production,
+// a preview deploy, a local run, an audit sweep. The baked page is the opposite
+// case. It is published once onto somebody else's domain, where a root-relative
+// src resolves against THEIR origin and 404s, so every asset it names has to
+// carry ours. Baking is the moment that difference is known, so it is where the
+// rewrite belongs, rather than forcing the live page to hardcode an origin it is
+// not always served from.
+function absolutize(src) {
+ return src.startsWith('/') && !src.startsWith('//') ? SITE_ORIGIN + src : src;
+}
+
// Replace each executable <script> in the body with an inert twin that preserves
// its source and type in data-* attributes. Non-executable scripts (ld+json) are
// left untouched. The boot reads these back to run the baked page when offline.
@@ -51,7 +65,7 @@ function inertizeBodyScripts(bodyInner) {
// is bulletproof regardless of how the source was authored.
const safe = code.replace(/<\/script/gi, '<\\/script');
const data = ['type="' + INERT_TYPE + '"', 'data-ibm-type="' + type + '"'];
- if (src) data.push('data-ibm-src="' + src.replace(/"/g, '&quot;') + '"');
+ if (src) data.push('data-ibm-src="' + absolutize(src).replace(/"/g, '&quot;') + '"');
return '<script ' + data.join(' ') + '>' + safe + '</script>';
});
}