How can I import a mesh with ImportMeshAsync if I need to access the API using an API Key?
Normally you would use an “x-api-key” header along with “my_api_key” to access the api and download the requested file, but there is no option in BABYLONJS for including headers.
async function getModel(scene) {
const result = await BABYLON.SceneLoader.ImportMeshAsync(
"",
"https://localhost:5000/download_mesh/Model.glb",
"",
scene
);
return result.meshes[0];
}
I think the problem is due to the lack of headers:
GET https://my.ip:5000/download_model/Model.glb net::ERR_ABORTED 403 (FORBIDDEN)
Uncaught (in promise) RuntimeError: Unable to load from blob:https://my.ip:8443/a22e01cc-4c03-4aa2-a130-8286f0280979: RangeError: Invalid typed array length: 20
Error 403 is the error that occurs when the API key is not sent, so the problem is that the headers are not working?
Access to fetch at 'https://192.168.15.88:5000/download/a.txt' from origin 'https://my.ip:8443' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
I’ll be working on fixing the CORS issue and will let you know if I find any other issues with BABYLONJS.