I am new with WebAssembly and I am trying with a sample Go WebAssembly project. After compiling into main.wasm, I am trying to fetching main.wasm using the following javascript code:
async function init() {
const go = new Go();
const filePath = './wasm/main.wasm';
const response = await fetch(filePath);
const buffer = await response.arrayBuffer();
const result = await WebAssembly.instantiate(
buffer,
go.importObject
);
go.run(result.instance);
}
init();
All I get is an error about CORS policy:
Access to fetch at 'file:///......../wasm/main.wasm' 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, isolated-app.
How can I bypass CORS policy when fetching local file in this case? Thank you in advanced.