Skip to content

Commit

Permalink
include credentials when fetching wasm binaries (#5287)
Browse files Browse the repository at this point in the history
* include credentials when fetching wasm binaries

Fetch API does not include cookies/credentials by default as XHR would.
To cause browsers to send a request with credentials included, add
credentials: 'include' to the init object you pass to the fetch()
method.

* use { credentials: 'same-origin' } here to have same behavior as XMLHttpRequest would, since we never used xhr.withCredentials = true
  • Loading branch information
ringoz authored and kripken committed Jun 13, 2017
1 parent abb142b commit 72c54ea
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/preamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -1981,7 +1981,7 @@ addOnPreRun(function() {
addRunDependency('preload_dynamicLibraries');
var binaries = [];
Module['dynamicLibraries'].forEach(function(lib) {
fetch(lib).then(function(response) {
fetch(lib, { credentials: 'same-origin' }).then(function(response) {
if (!response['ok']) {
throw "failed to load wasm binary file at '" + lib + "'";
}
Expand Down Expand Up @@ -2226,7 +2226,7 @@ function integrateWasmJS(Module) {
function getBinaryPromise() {
// if we don't have the binary yet, and have the Fetch api, use that
if (!Module['wasmBinary'] && typeof fetch === 'function') {
return fetch(wasmBinaryFile).then(function(response) {
return fetch(wasmBinaryFile, { credentials: 'same-origin' }).then(function(response) {
if (!response['ok']) {
throw "failed to load wasm binary file at '" + wasmBinaryFile + "'";
}
Expand Down

0 comments on commit 72c54ea

Please sign in to comment.