Add file:// as possible origin

Summary:
For Flipper Desktop, Electron based, the origin maybe file:// as shown in tests:

```
Refused socket connection from cross domain request, origin: file://, host: localhost:52342.

Expected origins: http://localhost:52342 or http://[::1]:52342 or http://::1:52342 or http://localhost:3000.
Expected hosts: localhost:52342 or [::1]:52342 or ::1:52342 or localhost:3000
```

This change effectively adds `file://` as a valid origin.

Reviewed By: passy

Differential Revision: D37212809

fbshipit-source-id: 311a93bb8872587d15c6be4329238af6b0f6988d
This commit is contained in:
Lorenzo Blasa
2022-06-16 10:45:08 -07:00
committed by Facebook GitHub Bot
parent 8a1e484d0c
commit 747b91da5f

View File

@@ -160,7 +160,9 @@ function addWebsocket(server: http.Server, config: Config) {
localhostIPV6NoBrackets,
localhostIPV4Electron,
];
const possibleOrigins = possibleHosts.map((host) => `http://${host}`);
const possibleOrigins = possibleHosts
.map((host) => `http://${host}`)
.concat(['file://']);
const verifyClient: VerifyClientCallbackSync = ({origin, req}) => {
const noOriginHeader = origin === undefined;