CORS, multiple file project

So a few days back I uploaded a question called Canvas not even showing, where I had problems with the Canvas not even showing when I opened my file and the only solution was to put all the CSS and JS code on my index.html file because of a protocol called CORS.

Now I have worked with HTML, CSS and simple javascript before and this problem has never occurred to me, how can I implement my code in multiple files so it can be more comfortable to work?

Vite may be of great help (or webpack + webpack-dev-server, or any other bundler + webserver combination.)

Well that’s what I used to setup my project, the problem still stands.

Unless you’re trying to load assets from a different origin (ie. a URL starting with a different domain) - you should not be getting CORS errors, also locally (assuming you’re not attempting to load using file:// urls.)

Could you show the error you’re getting when attempting to load a local file using Vite + the way you’re loading such a file?

Sorry for the late reply.

The code is the same as the post on the forum. I don’t have any error messages.

The idea is that my code didn’t work when in seperate files, and it did when in the same file and someone said it was because of CORS. But I don’t think that is right, as these are local files and it just doesn’t make sense.