Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/@expo/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

### 🐛 Bug fixes

- Reallow connections on `/expo-dev-plugins/broadcast` broadcast socket to local connections ([#42538](https://github.com/expo/expo/pull/42538) by [@kitten](https://github.com/kitten))
- Reallow connections on `/expo-dev-plugins/broadcast` broadcast socket to local connections ([#42538](https://github.com/expo/expo/pull/42538) by [@kitten](https://github.com/kitten)), ([#42705](https://github.com/expo/expo/pull/42705) by [@vonovak](https://github.com/vonovak))
- Fix `freeport-async` replacement ([#42509](https://github.com/expo/expo/pull/42509) by [@kitten](https://github.com/kitten))
- Use `require.resolve` to resolve `@expo/router-server` path ([#42516](https://github.com/expo/expo/pull/42516) by [@hassankhan](https://github.com/hassankhan))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,9 @@
import { WebSocket, WebSocketServer } from 'ws';

import { isMatchingOrigin } from '../../../utils/net';

interface DevToolsPluginWebsocketEndpointParams {
serverBaseUrl: string;
}

export function createDevToolsPluginWebsocketEndpoint({
serverBaseUrl,
}: DevToolsPluginWebsocketEndpointParams): Record<string, WebSocketServer> {
export function createDevToolsPluginWebsocketEndpoint(): Record<string, WebSocketServer> {
const wss = new WebSocketServer({ noServer: true });

wss.on('connection', (ws, request) => {
// Explicitly limit devtools websocket to loopback requests
if (request.headers.origin && !isMatchingOrigin(request, serverBaseUrl)) {
// NOTE: `socket.close` nicely closes the websocket, which will still allow incoming messages
// `socket.terminate` instead forcefully closes down the socket
ws.terminate();
return;
}

ws.on('message', (message, isBinary) => {
// Broadcast the received message to all other connected clients
wss.clients.forEach((client) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ export async function instantiateMetroAsync(
return middleware.use(metroMiddleware);
};

const devtoolsWebsocketEndpoints = createDevToolsPluginWebsocketEndpoint({ serverBaseUrl });
const devtoolsWebsocketEndpoints = createDevToolsPluginWebsocketEndpoint();
Object.assign(websocketEndpoints, devtoolsWebsocketEndpoints);
}

Expand Down
Loading