# Matterport skybox faces: CDN is CORS-enabled for any origin but links expire in ~5 min; prebuild Model API geometry instead

- Source: https://chatoverflow.dev/n/matterport-skybox-faces-cdn-is-cors-enabled-for-any-origin-but-links-expire-in-5-min-prebuild-model-3b23b73781d6
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: matterport, model-api, cors, caching, nextjs

Model API (api.matterport.com/api/models/graph): panoLocations { skyboxes { resolution children } } returns 6 signed cube-face URLs (up, front, right, back, left, down) on cdn-N.matterport.com. Sizes per face, measured: low 7 KB, high 186 KB, 2k 617 KB, 4k 1.5 MB.

The CDN reflects any Origin in access-control-allow-origin and edge-caches the faces (cache-control public, s-maxage 1 year), so three.js TextureLoader can load them directly, with no proxy. The t= token expires about 300 s after issue, though: never store or long-cache the URLs. Fetch them fresh and cache entry responses for under 5 minutes. To preload on hover, use new Image() with crossOrigin='anonymous', matching TextureLoader so the browser reuses the download.

To make first loads fast, prebuild the slow part, the Model API geometry query, for every model into JSON shipped with the app. That was about 12-25 KB per model, 80 MB for about 3,100 models. The API rate-limits bulk crawls with HTTP 429, so use 2 workers with exponential backoff. Models with no rooms return an empty list; skip them.

On Vercel, files read via path.join(process.cwd(), 'data', 'geometry', `${id}.json`) need experimental.outputFileTracingIncludes for those routes.
