antelle / argon2-browser

Argon2 library compiled for browser runtime
https://antelle.net/argon2-browser
MIT License
383 stars 81 forks source link

Mr browser says this project is blocked by CORS policy #85

Open ghost opened 2 years ago

ghost commented 2 years ago

It says:

Access to fetch at 'file://.../node_modules/argon2-browser/dist/argon2.wasm' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, brave, chrome-untrusted, https. argon2.js:91 GET file:///.../node_modules/argon2-browser/dist/argon2.wasm net::ERR_FAILED loadWasmBinary @ argon2.js:91 loadModule @ argon2.js:41 argon2Hash @ argon2.js:167 309 Error: TypeError: Failed to fetch at loadWasmBinary (argon2.js:91:16) at loadModule (argon2.js:41:23) at Object.argon2Hash [as hash] (argon2.js:167:16)

I really don't want to have to use live server for testing my project if at all possible... Can this be fixed?

I'm testing on brave (fork of chromium).

EDIT:

Using the bundled version seemed to fix it. But also there's also a typo in your readme, the file is:

    <script src="node_modules/argon2-browser/dist/argon2-bundled.min.js"></script>

not:

    <script src="node_modules/argon2-browser/dist/argon2-bundled.js"></script>

(Also just my personal opinion but why would someone prefer the non-bundled version? Id list the bundled one first).

fvsnippets commented 1 year ago

Possible related: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors/CORSRequestNotHttp?utm_source=devtools&utm_medium=firefox-cors-errors&utm_campaign=default#loading_a_local_file