From 6c91a4f0c3be2c770ce40ca663e92afe77ab9dcd Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Mon, 14 May 2018 10:52:12 -0400 Subject: [PATCH] Revert "Use Meteor.absoluteUrl again in dynamic-import fetchMissing function." This reverts commit 3b77bb51973cfbd98488a7203fc6d87c5c871a01. Should fix #9888. Sending dynamic import() requests to any origin other than location.host causes some browsers to send a preflight CORS request ( method:OPTIONS) to verify that the server allows the request, which was causing problems because the dynamic import() server expects method:POST. --- packages/dynamic-import/client.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/dynamic-import/client.js b/packages/dynamic-import/client.js index 298f61e69f..d34aef856f 100644 --- a/packages/dynamic-import/client.js +++ b/packages/dynamic-import/client.js @@ -121,7 +121,11 @@ var fetchURL = require("./common.js").fetchURL; function fetchMissing(missingTree) { return new Promise(function (resolve, reject) { - HTTP.call("POST", Meteor.absoluteUrl(fetchURL), { + // Always match the protocol (http or https) and the domain:port of + // the current page. + var url = "//" + location.host + fetchURL; + + HTTP.call("POST", url, { query: secretKey ? "key=" + secretKey : void 0, data: missingTree }, function (error, result) {