mosra / magnum-website

Website for the Magnum C++11 graphics engine
http://magnum.graphics/
16 stars 12 forks source link

Showcase examples not loading due to CORS rejection #4

Open vietjtnguyen opened 6 years ago

vietjtnguyen commented 6 years ago

Here's a console dump from Firefox Quantum 57.0.3 (64-bit) on macOS 10.12.6 (16G1036):

loading pref showConsoleLogs before prefs were initialised, you will not get the correct result
content-script.bundle.js:333:7
failed to asynchronously prepare wasm: TypeError: NetworkError when attempting to fetch resource.
EmscriptenApplication.js:15:9
TypeError: NetworkError when attempting to fetch resource.
EmscriptenApplication.js:19:9
TypeError: NetworkError when attempting to fetch resource.
EmscriptenApplication.js:15:9
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://static.magnum.graphics/showcase/textured-triangle/magnum-textured-triangle.wasm. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
uncaught exception: abort({}) at jsStackTrace@http://static.magnum.graphics/showcase/textured-triangle/magnum-textured-triangle.js:1:17995
stackTrace@http://static.magnum.graphics/showcase/textured-triangle/magnum-textured-triangle.js:1:18166
abort@http://static.magnum.graphics/showcase/textured-triangle/magnum-textured-triangle.js:1:232082
doNativeWasm/<@http://static.magnum.graphics/showcase/textured-triangle/magnum-textured-triangle.js:1:29561

If this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.

In particular: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://static.magnum.graphics/showcase/textured-triangle/magnum-textured-triangle.wasm. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

Similar thing in Chrome 63.0.3239.84 (Official Build) (64-bit):

Failed to load http://static.magnum.graphics/showcase/textured-triangle/magnum-textured-triangle.wasm: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://magnum.graphics' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
EmscriptenApplication.js:15 failed to asynchronously prepare wasm: TypeError: Failed to fetch
printErr @ EmscriptenApplication.js:15
(anonymous) @ magnum-textured-triangle.js:1
Promise rejected (async)
doNativeWasm @ magnum-textured-triangle.js:1
Module.asm @ magnum-textured-triangle.js:1
(anonymous) @ magnum-textured-triangle.js:1
EmscriptenApplication.js:19 TypeError: Failed to fetch
EmscriptenApplication.js:15 TypeError: Failed to fetch
printErr @ EmscriptenApplication.js:15
abort @ magnum-textured-triangle.js:1
(anonymous) @ magnum-textured-triangle.js:1
Promise rejected (async)
doNativeWasm @ magnum-textured-triangle.js:1
Module.asm @ magnum-textured-triangle.js:1
(anonymous) @ magnum-textured-triangle.js:1
magnum.graphics/:1 Uncaught (in promise) abort({}) at Error
    at jsStackTrace (http://static.magnum.graphics/showcase/textured-triangle/magnum-textured-triangle.js:1:17995)
    at stackTrace (http://static.magnum.graphics/showcase/textured-triangle/magnum-textured-triangle.js:1:18166)
    at abort (http://static.magnum.graphics/showcase/textured-triangle/magnum-textured-triangle.js:1:232082)
    at http://static.magnum.graphics/showcase/textured-triangle/magnum-textured-triangle.js:1:29561
    at <anonymous>
If this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.

Relevant part: Failed to load http://static.magnum.graphics/showcase/textured-triangle/magnum-textured-triangle.wasm: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Using the "Allow-Control-Allow-Origin: *" Chrome Extension resolves this on Chrome.

mosra commented 6 years ago

Hi, oops, thanks for the report!

I temporarily added the Allow-Control-Allow-Origin: * header to the server config (thank you for the hint), it seems to work now. Will fix this properly once the traffic calms down (don't want to break things too much now).