From 86dc9d0128f0f92087faf820aee32dad7fe86ef0 Mon Sep 17 00:00:00 2001 From: Rogerio Chaves Date: Sat, 25 Apr 2020 15:06:07 +0200 Subject: [PATCH] Changes for client version to work properly --- app/index.js | 2 +- app/lib/electron.js | 2 +- app/lib/express.js | 9 ++++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/index.js b/app/index.js index 21e9d2e..2d77c8e 100644 --- a/app/index.js +++ b/app/index.js @@ -12,7 +12,7 @@ if (mode == "client") { }, 1000); } -if (process.env.NODE_ENV != "production") { +if (mode == "server" && process.env.NODE_ENV != "production") { const chokidar = require("chokidar"); const watcher = chokidar.watch("./lib"); diff --git a/app/lib/electron.js b/app/lib/electron.js index 66796ae..86dc240 100644 --- a/app/lib/electron.js +++ b/app/lib/electron.js @@ -1,6 +1,6 @@ const { app, shell } = require("electron"); app.whenReady().then(() => { - let port = process.env.PORT || 3000; + let port = process.env.PORT || 7624; shell.openExternal(`http://localhost:${port}`); }); diff --git a/app/lib/express.js b/app/lib/express.js index 95c44e8..5593b1b 100644 --- a/app/lib/express.js +++ b/app/lib/express.js @@ -1,7 +1,7 @@ const ssb = require("./ssb-client"); const express = require("express"); const app = express(); -const port = process.env.PORT || 3000; +const port = process.env.PORT || 7624; const bodyParser = require("body-parser"); const { asyncRouter, @@ -44,7 +44,8 @@ if (SENTRY_DSN && process.env.NODE_ENV == "production") { app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: true })); app.set("view engine", "ejs"); -app.use(express.static("public")); +app.set('views', `${__dirname}/../views`); +app.use(express.static(`${__dirname}/../public`)); app.use(fileUpload()); const cookieSecret = process.env.COOKIES_SECRET || "set_cookie_secret_you_are_unsafe"; // has to be 32-bits @@ -55,7 +56,9 @@ const cookieOptions = { sameSite: "Lax", }; app.use(cookieParser(cookieSecret)); -app.use(cookieEncrypter(cookieSecret)); +if (mode != "client") { + app.use(cookieEncrypter(cookieSecret)); +} app.use(expressLayouts); app.set("layout", false); app.use(async (req, res, next) => {