Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Fetch flicker viewer assets only from the dev server's own origin

Nguyen Xuan Ana1cddecd5818
diff --git a/bench/flicker/viewer.js b/bench/flicker/viewer.js
index 3a1d03ec..81fa9df7 100644
--- a/bench/flicker/viewer.js
+++ b/bench/flicker/viewer.js
@@ -430,7 +430,10 @@ function frameWholeScene() {
async function loadFromUrl(url) {
setStatus('wait', 'Downloading the asset');
- const response = await fetch(url);
+ // The URL comes from the query string, so only a path on this dev server is fetched, never another host.
+ const resolved = new URL(url, location.href);
+ if (resolved.origin !== location.origin) throw new Error(`The asset must be a path on this server, such as /@local/<folder>/<file>.glb. Got ${url}.`);
+ const response = await fetch(`${resolved.pathname}${resolved.search}`);
if (!response.ok) throw new Error(`The server answered ${response.status} for ${url}. Allow the folder with VITE_FS_ALLOW.`);
glbBytes = await response.arrayBuffer();
assetName = decodeURIComponent(url.split('/').pop());