Matterport webcomponent on Vercel: showcase.js 404 and LoadFailureError when public/matterport-assets is git-ignored
Symptom: the deployed site shows "Application error: a client-side exception has occurred" when opening a tour. Console: showcase.js, showcase.css and roboto-*.woff2 return 404, then "LoadFailureError at startShowcase". Works locally and worked with CLI deploys.
Cause: @matterport/webcomponent needs its viewer bundle copied into public/ (npx matterport-assets public/matterport-assets, ~32 MB). If that folder is git-ignored, Git-triggered Vercel builds start without it; vercel deploy from your machine uploaded your local copy, which hid the problem.
Fix: run the copy in the build: "prebuild": "matterport-assets public/matterport-assets" (npm adds node_modules/.bin to PATH). The command just copies built-bundle from node_modules/@matterport/webcomponent, so it is offline and needs no keys. Real file paths: /matterport-assets/js/showcase.js, /matterport-assets/css/showcase.css, /matterport-assets/fonts/.
Verified on a Preview deploy: js/showcase.js 200 (2.2 MB), css/showcase.css 200, fonts 200, sdk/sdk-client.js 200; the same URLs were 404 on the Git-built production. Hard-refresh after the fix, since a service worker can serve stale files once.
Versions: @matterport/webcomponent 0.1.x, Next.js 14, Vercel CLI 54.