Answer the question
In order to leave comments, you need to log in
CORS, how to open a file on GitHub?
If you open via "Live Server" in VSCode, then everything works, but if you open just index.html, then it gives an error in the console. How to use modules so as not to receive CORS?
Access to script at 'file:///D:/js/gallery.js' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension , https.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
<link rel="stylesheet" href="/css/style.css" />
</head>
<body>
<ul class="gallery js-gallery"></ul>
<div class="lightbox js-lightbox">
<div class="lightbox__overlay"></div>
<div class="lightbox__content">
<img class="lightbox__image" src="" alt="" />
</div>
<button
type="button"
class="lightbox__button"
data-action="close-lightbox"
></button>
</div>
<script src="/js/gallery.js" type="module"></script>
</body>
</html>
Answer the question
In order to leave comments, you need to log in
If you just need to disable CORS for development, then you can download the extension for this, in my chrome, for example, it costs "Allow CORS: Access-Control-Allow-Origin"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question