Skip to content

Commit

Permalink
Merge pull request #1629 from reactioncommerce/safari-browser-policy
Browse files Browse the repository at this point in the history
Fix Safari websocket connection browser policy
  • Loading branch information
Aaron Judd committed Dec 20, 2016
2 parents 29053d7 + 348fa57 commit b8d0df1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions server/security/policy.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import url from "url";
import { BrowserPolicy } from "meteor/browser-policy-common";
import { WebApp } from "meteor/webapp";

Expand All @@ -23,8 +24,13 @@ if (process.env.NODE_ENV === "development") {
BrowserPolicy.content.allowConnectOrigin("https://localhost:*");
BrowserPolicy.framing.allowAll();
}
// allow production local websockets
BrowserPolicy.content.allowConnectOrigin("ws://localhost:*");

// get current hostname of app
const { hostname } = url.parse(Meteor.absoluteUrl());

// allow websockets (Safari fails without this)
BrowserPolicy.content.allowConnectOrigin(`ws://${hostname}`);
BrowserPolicy.content.allowConnectOrigin(`wss://${hostname}`);

BrowserPolicy.content.allowOriginForAll("*.facebook.com");
BrowserPolicy.content.allowOriginForAll("*.fbcdn.net");
Expand Down

0 comments on commit b8d0df1

Please sign in to comment.