fix: ws prefix url in electron (#1896)

This commit is contained in:
Peng Xiao
2023-04-12 22:11:47 +08:00
committed by GitHub
parent 25d7f7c848
commit 95aa86cdf0
17 changed files with 237 additions and 261 deletions

View File

@@ -1,4 +1,4 @@
import { protocol } from 'electron';
import { protocol, session } from 'electron';
import { join } from 'path';
export function registerProtocol() {
@@ -20,4 +20,15 @@ export function registerProtocol() {
}
});
}
session.defaultSession.webRequest.onHeadersReceived(
(responseDetails, callback) => {
const { responseHeaders, url } = responseDetails;
if (responseHeaders) {
responseHeaders['Access-Control-Allow-Origin'] = ['*'];
}
callback({ responseHeaders });
}
);
}