From f9c769aee3e0b779dd0435262e1ecba47983865b Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Wed, 22 Dec 2021 03:17:46 -0800 Subject: [PATCH] Fix Metro crash if no origin header is set Summary: Changelog: Work-around for missing `origin` header problem https://github.com/facebook/flipper/issues/3189; causing Metro to crash when Flipper tries to connect Will follow up with separate fix in React Native itself as well Reviewed By: nikoant Differential Revision: D33276414 fbshipit-source-id: 34d1510262ac24172ac1c6660799bb755b0f1f11 --- .../src/devices/metro/metroDeviceManager.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/desktop/flipper-server-core/src/devices/metro/metroDeviceManager.tsx b/desktop/flipper-server-core/src/devices/metro/metroDeviceManager.tsx index 0b7cfe73d..27712a1d8 100644 --- a/desktop/flipper-server-core/src/devices/metro/metroDeviceManager.tsx +++ b/desktop/flipper-server-core/src/devices/metro/metroDeviceManager.tsx @@ -65,7 +65,11 @@ export default (flipperServer: FlipperServerImpl) => { if (await isMetroRunning()) { try { - const _ws = new WebSocket(METRO_LOGS_ENDPOINT); + const _ws = new WebSocket(METRO_LOGS_ENDPOINT, { + // temporarily hardcoded URL, as without an origin header, metro will crash, see + // https://github.com/facebook/flipper/issues/3189 + origin: 'http://localhost:3000/flipper', + }); _ws.onopen = () => { clearTimeout(guard);