From 9a5062ce0aaffa4a0625383649b4b7671554a3c5 Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Tue, 31 Mar 2020 15:33:11 +0100 Subject: [PATCH] Fix: allow Hermes Debugger to connect from Flipper (#1086) * Fix: allow Hermes Debugger to connect from Flipper This change reflects D20526486 by @rickhanlonii at Facebook: when Running Hermes Debugger from inside Flipper, the origin is localhost, but not the metro port. This fixes https://github.com/facebook/flipper/issues/660#issuecomment-606239984 * Fixed compile errors * Fix lint error --- .../server/middleware/getSecurityHeadersMiddleware.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/cli/src/commands/server/middleware/getSecurityHeadersMiddleware.ts b/packages/cli/src/commands/server/middleware/getSecurityHeadersMiddleware.ts index 498ce8b6f..5fedf4898 100644 --- a/packages/cli/src/commands/server/middleware/getSecurityHeadersMiddleware.ts +++ b/packages/cli/src/commands/server/middleware/getSecurityHeadersMiddleware.ts @@ -11,13 +11,10 @@ export default function getSecurityHeadersMiddleware( res: http.ServerResponse, next: (err?: any) => void, ) { - // @ts-ignore Property 'client' does not exist on type 'IncomingMessage', verify - const address = req.client.server.address(); - // Block any cross origin request. if ( - req.headers.origin && - req.headers.origin !== `http://localhost:${address.port}` + typeof req.headers.origin === 'string' && + !req.headers.origin.match(/^https?:\/\/localhost:/) ) { next( new Error(