Search code examples
google-chromehttpbabylonjs

Why I can't import .babylon file to the babylon JS?


When i tried to import babylon file, i received the error Access to XMLHttpRequest at 'myfilepath' from origin 'null' has been blocked by CORS policy: I have no idea on CORS, and please help me by briefing it to the beginner level.

1)Access to XMLHttpRequest at 'file:///C:/Users/AJDA/Documents/Palatisation/web%20files/box.babylon' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

2)BJS - [17:27:13]: Unable to import meshes from box.babylon: importMesh of undefined from undefined version: undefined, exporter version: undefinedimportMesh has failed JSON parse m._ErrorEnabled @ babylon.js:1


Solution

  • Hello this is unfortunate but this is a security constraint enforced by browsers. Files can only be served from a webserver (like apache, IIS, etc...) from your localhost