use vite project, viteStaticCopy to copy cesium statics
when cross origin, other assets is ok, but the webwork goes wrong.
1.what i a encounter(Problem Description)
I am developing an SDK based on Cesium within a Vite project. After using viteStaticCopy
to copy all of Cesium’s static files, I encounter a problem when accessing these files from another Vite project (running on a different localhost port). While images do not trigger any cross-origin issues, web workers do face these problems. However, when I use the official Cesium build package, no cross-origin issues arise at all!
2.project files
2.1 sdk vite project
viteMapSdkJs.zip (25.3 MB)
2.2 request html file(use another localhost port!)
testThree.zip (655 Bytes)
2.2.1 run the testThree.html in the other local port or use vscode liveServer
2.3 when i use the cesium official build, everything is ok
2.4 when i use my vite build, then webwork cross origin!
the error text conetent as follow:
SecurityError: Failed to construct ‘Worker’: Script at ‘http://localhost:5178/dcjtMaps/Workers/createVerticesFromQuantizedTerrainMesh.js’ cannot be accessed from origin ‘http://127.0.0.1:5500’.
Error: Failed to construct ‘Worker’: Script at ‘http://localhost:5178/dcjtMaps/Workers/createVerticesFromQuantizedTerrainMesh.js’ cannot be accessed from origin ‘http://127.0.0.1:5500’.
at createWorker (http://localhost:5178/dcjtMaps/DcjtMap.umd.js:61:287)
at TaskProcessor.scheduleTask (http://localhost:5178/dcjtMaps/DcjtMap.umd.js:61:2145)
at QuantizedMeshTerrainData.createMesh (http://localhost:5178/dcjtMaps/DcjtMap.umd.js:14796:26457)
at transform (http://localhost:5178/dcjtMaps/DcjtMap.umd.js:11715:10522)
at processTerrainStateMachine (http://localhost:5178/dcjtMaps/DcjtMap.umd.js:11715:8181)
at GlobeSurfaceTile.processStateMachine (http://localhost:5178/dcjtMaps/DcjtMap.umd.js:11715:4641)
at GlobeSurfaceTileProvider.loadTile (http://localhost:5178/dcjtMaps/DcjtMap.umd.js:11715:130087)
at processSinglePriorityLoadQueue (http://localhost:5178/dcjtMaps/DcjtMap.umd.js:11715:192117)
at processTileLoadQueue (http://localhost:5178/dcjtMaps/DcjtMap.umd.js:11715:191677)
at QuadtreePrimitive.endFrame (http://localhost:5178/dcjtMaps/DcjtMap.umd.js:11715:181874)
3.I know run in the same origin or proxy can fix this problem,but my requirements must run in diffrent origin and can’t use proxy
because i use the sandpack, the sand pack will sead the code to the remote server!
and i think there must something run in my vite sdk project