In a Vue app that I'm starting to build, which uses Vue from the CDN, I cannot get past the console error:
Access to script at 'file:///C:/files/development/vue/reading_schedule/json/books.json' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, 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">
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
</head>
<body>
<div id="app">
<div>{{ title }}</div>
</div>
<script type="module">
import * as books from './json/books.json';
new Vue ({
el: "#app",
data() {
return {
title: 'Reading Schedule'
}
},
created() {
document.title = this.title;
// console.log(books);
},
methods: {
}
});
</script>
</body>
</html>
My Vue app development experience thus far has been creating apps in the Vue CLI and importing JSON into those is straightforward and without CORS policy console errors.
Is it possible to get the above code to work somehow?