Skip to content

Commit

Permalink
fix(agent): make ws callbacks no-cors
Browse files Browse the repository at this point in the history
  • Loading branch information
blakebyrnes committed Oct 27, 2024
1 parent 544edc8 commit 898d6b2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions agent/main/lib/WebsocketSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,11 @@ function injectedScript(): void {
const url = `${this.host}:${this.port}?secret=${this.secret}&clientId=${clientId}`;
// This will signal to network manager we are trying to make websocket connection
// This is needed later to map clientId to frameId
// eslint-disable-next-line no-console
fetch(`http://${url}`).catch(error => console.log(error));
fetch(`http://${url}`, {
mode: 'no-cors',
})
// eslint-disable-next-line no-console
.catch(error => console.log(error));
let callback: WebsocketCallback;
try {
const socket = new WebSocket(`ws://${url}`);
Expand Down
3 changes: 2 additions & 1 deletion timetravel/lib/MirrorNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ export default class MirrorNetwork {
responseCode: 200,
responseHeaders: [
{ name: 'Content-Type', value: 'text/html; charset=utf-8' },
{ name: 'Content-Security-Policy', value: "script-src 'nonce-hero-timetravel'" },
{ name: 'Content-Security-Policy', value: "script-src 'nonce-hero-timetravel'; connect-src 'self' ws://websocket.localhost:* http://websocket.localhost:*" },
{ name: 'Access-Control-Allow-Origin', value: '*' },
],
body: Buffer.from(`${doctype}<html><head></head><body></body></html>`).toString('base64'),
};
Expand Down

0 comments on commit 898d6b2

Please sign in to comment.