Skip to content
Snippets Groups Projects
Verified Commit 29bff65a authored by Miniontoby's avatar Miniontoby :writing_hand_tone1:
Browse files

Updated productionServer

Updated productionServer to set the ORIGIN variable
And to make it executable when double clicking on it on windows
parent 84103703
No related branches found
No related tags found
No related merge requests found
import http from 'http';
import express from 'express';
import injectSocketIO from './socketIoHandler.js';
import { handler } from './build/handler.js';
const app = express();
const server = http.createServer(app);
// Inject SocketIO
injectSocketIO(server);
// SvelteKit handlers
app.use(handler);
server.listen(3000, () => {
console.log('Running on http://localhost:3000');
});
\ No newline at end of file
if (!process.env?.PORT)
process.env.PORT = '3000';
if (!process.env?.ORIGIN)
process.env.ORIGIN = `http://localhost:${process.env.PORT}`;
/*@cc_on
@if (@_jscript)
var objShell = new ActiveXObject('Shell.Application');
var pathSelf = WScript.ScriptFullName;
objShell.ShellExecute('cmd.exe', '/C node.exe ' + pathSelf + ' & pause');
WScript.Quit();
@else @*/
import './envFixer.js'; // Used to set the env, since for some reason imports are done BEFORE code executing, even if your code is above the imports...
import http from 'http';
import express from 'express';
import injectSocketIO from '../socketIoHandler.js';
import { handler } from '../build/handler.js'; // We need to inject the ORIGIN, and for some reason the imports are done BEFORE any other line...
const app = express();
const server = http.createServer(app);
// Inject SocketIO
injectSocketIO(server);
// SvelteKit handlers
app.use(handler);
server.listen(Number(process.env.PORT ?? 3000), () => {
console.log(`Running on ${process.env.ORIGIN}`);
});
/*@end @*/
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment