KnicKnic / WASM-ImageMagick

Webassembly compilation of https://github.com/ImageMagick/ImageMagick & samples

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Refused to execute script from 'http://localhost:3000/static/js/magick.js' because its MIME type ('text/html') is not executable

greghesp opened this issue · comments

I'm using this in a React project and I get an error in the console saying

Refused to execute script from 'http://localhost:3000/static/js/magick.js' because its MIME type ('text/html') is not executable

var magickJsCurrentPath = 'http://localhost:3000/static/js/magick.js';
importScripts(magickJsCurrentPath);```

I am not advanced with React, but this appears to be a problem on your side. The webserver is returning text/html for the mimetype of http://localhost:3000/static/js/magick.js when it should return text/javascript

It seems to be an issue when bundling, as this is the code generated by the GenerateMagickWorkerText function at runtime:

var magickJsCurrentPath = 'http://localhost:3000/static/js/magick.js';
importScripts(magickJsCurrentPath);

but after bundling, there is no file at /static/js/magick.js, and so the import defaults to the static index.html

It's not a problem with the server serving the wrong filetype, but with there being no script where the package expects there to be one. I don't exactly see why magickApi.js expects there to be a js file there, but I'm not at all familiar with the code, so maybe @KnicKnic you might have an idea?

Turns out I forgot to read the readme properly, and @greghesp Probably did the same. If anyone else finds this, you need to copy the magick.wasm and magick.js into your static folder, as described here