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
This commit is contained in:
Michel Weststrate
2021-12-22 03:17:46 -08:00
committed by Facebook GitHub Bot
parent bc1a838921
commit f9c769aee3

View File

@@ -65,7 +65,11 @@ export default (flipperServer: FlipperServerImpl) => {
if (await isMetroRunning()) { if (await isMetroRunning()) {
try { 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 = () => { _ws.onopen = () => {
clearTimeout(guard); clearTimeout(guard);