PS: for an example of a WASM webpage you can look at the github-pages repo 
for my sokol-samples page

The github-pages repo is here: https://github.com/floooh/sokol-html5

Producing this webpage: https://floooh.github.io/sokol-html5/

The interesting files are here:

https://github.com/floooh/sokol-html5/tree/master/wasm

For each demo, there's a .html, .js and .wasm file. For instance the files 
for the triangle demo (
https://floooh.github.io/sokol-html5/wasm/triangle-sapp.html) would be:

https://github.com/floooh/sokol-html5/blob/master/wasm/triangle-sapp.html

https://github.com/floooh/sokol-html5/blob/master/wasm/triangle-sapp.js

https://github.com/floooh/sokol-html5/blob/master/wasm/triangle-sapp.wasm

I guess the interesting part is that all URL files are relative, there's no 
"http://hostname/..."; part anywhere, only the filenames (I'm not doing 
anything special for this during compilation, this seems to be emscripten's 
default). This basically ensures that that the demo works locally, as well 
as
any domain / URL.



On Wednesday, 3 April 2019 12:53:32 UTC+2, Floh wrote:
>
> It looks like you're loading the JS file from a different URL than the 
> WASM file:
>
> http://www.coolprop.sourceforge.net
>
> vs 
>
> http://www.coolprop.dreamhosters.com:8010
>
> The easiest solution is to host all files (.html, .js, .wasm) from the 
> same domain (so either all files
> on sourceforge, or on dreamhoster, but not both).
>
> The complicated solution (which I haven't done so far) is to change the 
> configuration of the
> dreamhoster webserver to accept cross-origin requests from the sourceforge 
> domain (assuming dreamhoster
> even allows this sort of configuration). Google for 'CORS whitelist' or 
> similar.
>
> On Sunday, 31 March 2019 00:27:54 UTC+1, Ian Bell wrote:
>>
>> I have an enscripten-wrapped C++ library, and running it in a local 
>> webserver works fine.  But when I try to drop the .js and .wasm files onto 
>> another server and include it in a block like this:
>>
>> <script src="http://www.coolprop.sourceforge.net/jscript/coolprop.js 
>> <http://www.google.com/url?q=http%3A%2F%2Fwww.coolprop.sourceforge.net%2Fjscript%2Fcoolprop.js&sa=D&sntz=1&usg=AFQjCNGPgBkXNGuj2SO0568jYnvFf85XpA>"></script
>>  >
>>
>> In my HTML, I get CORS errors (see below). I've set the MIME type on the 
>> WASM successfully, but this is a classic CORS problem I surmise. 
>>
>> Can somebody point me to an example of a properly functioning publishing of 
>> js+wasm combo that can be successfully included in another script in the 
>> manner that I have tried to do?  The emscripten docs on this topic are 
>> decidedly unhelpful: 
>> https://emscripten.org/docs/compiling/Deploying-Pages.html#prepare-for-the-web-environment
>>
>> wasm streaming compile failed: TypeError: NetworkError when attempting to 
>> fetch resource. coolprop.js:1651:11 
>> <http://www.coolprop.dreamhosters.com:8010/binaries/Javascript/coolprop.js>
>>
>> falling back to ArrayBuffer instantiation coolprop.js:1652:11 
>> <http://www.coolprop.dreamhosters.com:8010/binaries/Javascript/coolprop.js>
>> Cross-Origin
>>  Request Blocked: The Same Origin Policy disallows reading the remote 
>> resource at 
>> http://
>> www.coolprop.dreamhosters.com:8010/binaries/Javascript/coolprop.wasm.
>>  (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).[Learn More] 
>> both async and sync fetching of the wasm failed coolprop.js:10604:5 
>> <http://www.coolprop.dreamhosters.com:8010/binaries/Javascript/coolprop.js>
>> both async and sync fetching of the wasm failed coolprop.js:10605:5 
>> <http://www.coolprop.dreamhosters.com:8010/binaries/Javascript/coolprop.js>
>> failed
>>  to asynchronously prepare wasm: abort("both async and sync fetching of 
>> the wasm failed") at 
>> jsStackTrace@http://
>> www.coolprop.dreamhosters.com:8010/binaries/Javascript/coolprop.js:1048:13
>> stackTrace@http://
>> www.coolprop.dreamhosters.com:8010/binaries/Javascript/coolprop.js:1065:12
>> abort@http://
>> www.coolprop.dreamhosters.com:8010/binaries/Javascript/coolprop.js:10615:44
>> getBinary@http://
>> www.coolprop.dreamhosters.com:8010/binaries/Javascript/coolprop.js:1554:7
>> getBinaryPromise/<@http://
>> www.coolprop.dreamhosters.com:8010/binaries/Javascript/coolprop.js:1568:16
>>  coolprop.js:1638:9 
>> <http://www.coolprop.dreamhosters.com:8010/binaries/Javascript/coolprop.js>
>> abort("both
>>  async and sync fetching of the wasm failed") at 
>> jsStackTrace@http://
>> www.coolprop.dreamhosters.com:8010/binaries/Javascript/coolprop.js:1048:13
>> stackTrace@http://
>> www.coolprop.dreamhosters.com:8010/binaries/Javascript/coolprop.js:1065:12
>> abort@http://
>> www.coolprop.dreamhosters.com:8010/binaries/Javascript/coolprop.js:10615:44
>> getBinary@http://
>> www.coolprop.dreamhosters.com:8010/binaries/Javascript/coolprop.js:1554:7
>> getBinaryPromise/<@http://
>> www.coolprop.dreamhosters.com:8010/binaries/Javascript/coolprop.js:1568:16
>>  coolprop.js:10604:5 
>> <http://www.coolprop.dreamhosters.com:8010/binaries/Javascript/coolprop.js>
>> abort("both
>>  async and sync fetching of the wasm failed") at 
>> jsStackTrace@http://
>> www.coolprop.dreamhosters.com:8010/binaries/Javascript/coolprop.js:1048:13
>> stackTrace@http://
>> www.coolprop.dreamhosters.com:8010/binaries/Javascript/coolprop.js:1065:12
>> abort@http://
>> www.coolprop.dreamhosters.com:8010/binaries/Javascript/coolprop.js:10615:44
>> getBinary@http://
>> www.coolprop.dreamhosters.com:8010/binaries/Javascript/coolprop.js:1554:7
>> getBinaryPromise/<@http://
>> www.coolprop.dreamhosters.com:8010/binaries/Javascript/coolprop.js:1568:16
>>  coolprop.js:10605:5 
>> <http://www.coolprop.dreamhosters.com:8010/binaries/Javascript/coolprop.js>
>> Cross-Origin
>>  Request Blocked: The Same Origin Policy disallows reading the remote 
>> resource at 
>> http://
>> www.coolprop.dreamhosters.com:8010/binaries/Javascript/coolprop.wasm.
>>  (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).[Learn More]
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to