notherbase-fs 4.0.20 → 4.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/notherbase-fs.js +4 -8
  2. package/package.json +1 -1
package/notherbase-fs.js CHANGED
@@ -11,7 +11,6 @@ import SpiritWorld from "./controllers/spirit-world.js";
11
11
  import favicon from 'serve-favicon';
12
12
  import session from 'express-session';
13
13
  import MongoStore from 'connect-mongo';
14
- import cors from 'cors';
15
14
 
16
15
 
17
16
  /**
@@ -40,23 +39,20 @@ class NotherBaseFS {
40
39
 
41
40
  //be safe, needs to be before session
42
41
  if (process.env.PRODUCTION == "true") this.app.set('trust proxy', 1);
43
-
44
- this.app.use(cors());
45
42
 
46
43
  let baseKeys = Object.keys(this.bases);
44
+ let store = MongoStore.create({ mongoUrl: process.env.MONGODB_URI });
47
45
  for (let i = 0; i < baseKeys.length; i++) {
48
46
  this.bases[baseKeys[i]].static = express.static(this.bases[baseKeys[i]].directory + "/public");
49
47
  this.bases[baseKeys[i]].favicon = favicon(this.bases[baseKeys[i]].directory + this.bases[baseKeys[i]].icon);
50
48
  this.bases[baseKeys[i]].session = session({
51
- store: MongoStore.create({ mongoUrl: process.env.MONGODB_URI }),
49
+ store: store,
52
50
  secret: process.env.SECRET,
53
51
  name: baseKeys[i] + '-session-id',
54
52
  resave: false,
55
53
  saveUninitialized: false,
56
- proxy: process.env.PRODUCTION == "true",
57
54
  cookie: {
58
55
  secure: process.env.PRODUCTION == "true",
59
- sameSite: process.env.PRODUCTION == "true" ? 'none' : 'lax',
60
56
  maxAge: 1000 * 60 * 60 * 24 * 28 // 28 days
61
57
  }
62
58
  });
@@ -79,8 +75,6 @@ class NotherBaseFS {
79
75
  this.bases[req.hosting].favicon(req, res, next);
80
76
  });
81
77
 
82
-
83
-
84
78
  //enable cookies
85
79
  this.app.use((req, res, next) => {
86
80
  this.bases[req.hosting].session(req, res, next);
@@ -97,6 +91,8 @@ class NotherBaseFS {
97
91
  req.globals = globals;
98
92
  req.db = Models;
99
93
  req.lock = false;
94
+ // enables sessions only if the protocol is https and we are in production, or if we are in development
95
+ req.sessionsEnabled = (process.env.PRODUCTION == "true" && req.secure) || process.env.PRODUCTION == "false";
100
96
  next();
101
97
  });
102
98
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notherbase-fs",
3
- "version": "4.0.20",
3
+ "version": "4.0.22",
4
4
  "description": "Functions to help make developing for NotherBase easier.",
5
5
  "exports": "./notherbase-fs.js",
6
6
  "scripts": {