feat: Add server dependencies and initial application components.
All checks were successful
Build and Release / build-and-release (push) Successful in 15m24s

This commit is contained in:
Bryan1029384756
2026-02-21 15:06:36 -06:00
parent cbda60757c
commit 84aa458012
17 changed files with 1288 additions and 12 deletions

View File

@@ -8,6 +8,21 @@ const https = require('https');
const http = require('http');
const { checkForUpdates } = require('./updater.cjs');
function loadEnvVar(varName) {
const envFiles = [
path.join(__dirname, '../../.env.local'),
path.join(__dirname, '../../.env'),
];
for (const envFile of envFiles) {
try {
const content = fs.readFileSync(envFile, 'utf8');
const match = content.match(new RegExp(`^${varName}=(.+)$`, 'm'));
if (match) return match[1].trim().replace(/^['"]|['"]$/g, '');
} catch {}
}
return null;
}
// --- Settings persistence ---
const SETTINGS_FILE = path.join(app.getPath('userData'), 'settings.json');
const DEFAULT_SETTINGS = {
@@ -73,6 +88,27 @@ function createWindow() {
mainWindow = new BrowserWindow(windowOptions);
// Fix LiveKit WebSocket/CORS for dev mode — rewrite Origin header and inject CORS response headers
const livekitWssUrl = loadEnvVar('VITE_LIVEKIT_URL');
if (livekitWssUrl) {
const livekitHttpsOrigin = livekitWssUrl.replace(/^wss:\/\//, 'https://').replace(/^ws:\/\//, 'http://');
const livekitHost = new URL(livekitHttpsOrigin).hostname;
const filter = { urls: [`*://${livekitHost}/*`] };
mainWindow.webContents.session.webRequest.onBeforeSendHeaders(filter, (details, callback) => {
details.requestHeaders['Origin'] = livekitHttpsOrigin;
callback({ requestHeaders: details.requestHeaders });
});
mainWindow.webContents.session.webRequest.onHeadersReceived(filter, (details, callback) => {
const headers = details.responseHeaders || {};
headers['Access-Control-Allow-Origin'] = ['*'];
headers['Access-Control-Allow-Headers'] = ['*'];
headers['Access-Control-Allow-Methods'] = ['GET, POST, OPTIONS'];
callback({ responseHeaders: headers });
});
}
if (settings.isMaximized) {
mainWindow.maximize();
}

View File

@@ -1,7 +1,7 @@
{
"name": "@discord-clone/electron",
"private": true,
"version": "1.0.31",
"version": "1.0.32",
"description": "Discord Clone - Electron app",
"author": "Moyettes",
"type": "module",