mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-28 21:49:40 +02:00
refactor(deep-links, quick-ask, window): replace localhost references with dynamic server origin retrieval
This commit is contained in:
parent
a2847664c8
commit
fe797e65d6
4 changed files with 16 additions and 11 deletions
|
|
@ -3,6 +3,7 @@ import { app, utilityProcess } from 'electron';
|
|||
import { getPort } from 'get-port-please';
|
||||
|
||||
const isDev = !app.isPackaged;
|
||||
const SERVER_HOST = '127.0.0.1';
|
||||
let serverPort = 3000;
|
||||
let nextServerProcess: ReturnType<typeof utilityProcess.fork> | null = null;
|
||||
|
||||
|
|
@ -10,6 +11,10 @@ export function getServerPort(): number {
|
|||
return serverPort;
|
||||
}
|
||||
|
||||
export function getServerOrigin(): string {
|
||||
return `http://${SERVER_HOST}:${serverPort}`;
|
||||
}
|
||||
|
||||
function getStandalonePath(): string {
|
||||
if (isDev) {
|
||||
return path.join(__dirname, '..', '..', 'surfsense_web', '.next', 'standalone', 'surfsense_web');
|
||||
|
|
@ -44,7 +49,7 @@ export async function startNextServer(): Promise<void> {
|
|||
env: {
|
||||
...process.env,
|
||||
PORT: String(serverPort),
|
||||
HOSTNAME: '127.0.0.1',
|
||||
HOSTNAME: SERVER_HOST,
|
||||
NODE_ENV: 'production',
|
||||
},
|
||||
serviceName: 'SurfSense Next Server',
|
||||
|
|
@ -75,7 +80,7 @@ export async function startNextServer(): Promise<void> {
|
|||
child.once('exit', startupExitHandler);
|
||||
});
|
||||
|
||||
const ready = await Promise.race([waitForServer(`http://localhost:${serverPort}`), exited]);
|
||||
const ready = await Promise.race([waitForServer(getServerOrigin()), exited]);
|
||||
if (startupExitHandler) {
|
||||
child.removeListener('exit', startupExitHandler);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue