hubs
hubs copied to clipboard
Fix scene and media failing to load for local dev against hubs cloud
See also #3972
Two issues disrupting local dev against hubs cloud since February:
- Assets are loaded via
https://${local ip address}:8080/...
instead of localhost. Browsers see this as a different domain and won't transfer your certificate exception from localhost, so the requests get rejected and you get "Scene failed to load" - Internal domains (AWS recipe 2) are not included in non-cors-proxy list, so they attempt to proxy and fail. Images and videos from the selfie cam just show as broken links
This fixes both for me, but I doubt it is the correct solution as it is just removing that localIp
logic that must serve some purpose. Looking for guidance on what that purpose is to find a solution that works for both
┆Issue is synchronized with this Jira Task
I think in here you can just comment the internalIp
logic, keeping the ability to use HOST_IP:
const localIp = process.env.HOST_IP || (await internalIp.v4()) || "localhost";
Nice find on the proxying, been annoying me for a while.
It doesn't seem to solve the issue of assets not loading for local development (npm run start
) with Hubs Cloud:
The scene loads fine through the proxy ( https://localhost:8080/cors-proxy/https://internal...workers.dev/files/333...6f.bin ). Other assets dropped into the room are using the proxy but never load; trying to manually fetch them unproxied from localhost:8080 will throw a CORS error: Access to fetch at 'https://internal...workers.dev/files/012...77.png?token=123' from origin 'https://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
.
Which is somewhat coherent with this comment but it doesn't work.
I am trying to access with my IP address instead of localhost, but it occurs some errors in fetching. So I can't join to the room with IP address.
The "localIp" logic is used for accessing the local dev server via ip (such as on a mobile device). The intended way to add additional NON_CORS_PROXY_DOMAINs is to add them to a .env file. You will still need to manually make CORS/CSP changes in your hubs instance admin panel.