Skip to content

Commit 049dbdc

Browse files
committed
Add security header
1 parent 9c9d369 commit 049dbdc

File tree

1 file changed

+12
-2
lines changed
  • resources/js/electron-plugin/src

1 file changed

+12
-2
lines changed

resources/js/electron-plugin/src/index.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type CrossProcessExports from "electron";
2-
import { app } from "electron";
3-
import {initialize} from "@electron/remote/main/index.js";
2+
import { app, session } from "electron";
3+
import { initialize } from "@electron/remote/main/index.js";
44
import state from "./server/state.js";
55
import { electronApp, optimizer } from "@electron-toolkit/utils";
66
import {
@@ -107,6 +107,16 @@ class NativePHP {
107107
await this.startPhpApp();
108108
this.startScheduler();
109109

110+
const filter = {
111+
urls: [`http://127.0.0.1:${state.phpPort}/*`]
112+
};
113+
114+
session.defaultSession.webRequest.onBeforeSendHeaders(filter, (details, callback) => {
115+
details.requestHeaders['X-NativePHP-Secret'] = state.randomSecret;
116+
117+
callback({ requestHeaders: details.requestHeaders });
118+
});
119+
110120
await notifyLaravel("booted");
111121
}
112122

0 commit comments

Comments
 (0)