Skip to content

Free, open-source 3D sculpting for Linux, macOS and Windows: dense meshes, remeshing, painting, built-in AI (image/text to 3D), Send to Unreal, game-ready LODs, Gaussian splats and OpenUSD.

Relay: allow the Content-Type header in CORS (the AR page's share post failed its preflight)

islandmed2ee039e798c2
diff --git a/services/link-worker/src/index.js b/services/link-worker/src/index.js
index a6782eb6..12247f9f 100644
--- a/services/link-worker/src/index.js
+++ b/services/link-worker/src/index.js
@@ -123,6 +123,7 @@ function respond(body, status, origin, type = "application/json") {
if (origin) {
headers["Access-Control-Allow-Origin"] = origin;
headers["Access-Control-Allow-Methods"] = "GET, POST, HEAD";
+ headers["Access-Control-Allow-Headers"] = "Content-Type"; // the AR page posts model/gltf-binary
headers["Access-Control-Expose-Headers"] = "X-Version";
headers["Access-Control-Max-Age"] = "86400";
headers["Vary"] = "Origin";
diff --git a/services/link-worker/test/relay.test.mjs b/services/link-worker/test/relay.test.mjs
index 418daa72..ab83fdcd 100644
--- a/services/link-worker/test/relay.test.mjs
+++ b/services/link-worker/test/relay.test.mjs
@@ -48,6 +48,7 @@ test("topics, messages, sizes and origins are checked", async () => {
const pre = await worker.fetch(new Request(`${BASE}/relay/${TOPIC}`, { method: "OPTIONS", headers: { Origin: PAGE } }), env);
assert.equal(pre.status, 204);
assert.equal(pre.headers.get("Access-Control-Allow-Origin"), PAGE);
+ assert.equal(pre.headers.get("Access-Control-Allow-Headers"), "Content-Type");
assert.equal((await worker.fetch(new Request(`${BASE}/`), env)).status, 200);
});
diff --git a/website/link/ar.html b/website/link/ar.html
index 998aeca6..a0cbd2fa 100644
--- a/website/link/ar.html
+++ b/website/link/ar.html
@@ -234,7 +234,7 @@ $("google").onclick = async () => {
$("google").disabled = true;
$("google").textContent = "Preparing...";
try {
- const r = await fetch(`${shareUrl}?v=${shownVersion}`, { method: "POST", body: currentModel });
+ const r = await fetch(`${shareUrl}?v=${shownVersion}`, { method: "POST", body: await currentModel.arrayBuffer() });
if (!r.ok) throw new Error((await r.json().catch(() => ({}))).error || "HTTP " + r.status);
const page = location.href.split("#")[0];
$("googleOpen").href = "intent://arvr.google.com/scene-viewer/1.0?file=" + encodeURIComponent(`${shareUrl}?v=${shownVersion}`) +