env variables for easier dev setup
This commit is contained in:
@@ -19,10 +19,7 @@ declare module "http" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const sessionMiddleware = session({
|
const sessionMiddleware = session({
|
||||||
store: new PGSession({
|
store: new PGSession({ pool: db, createTableIfMissing: true }),
|
||||||
pool: db,
|
|
||||||
createTableIfMissing: true
|
|
||||||
}),
|
|
||||||
secret: process.env.SESSION_SECRET || "whatever this is",
|
secret: process.env.SESSION_SECRET || "whatever this is",
|
||||||
resave: false,
|
resave: false,
|
||||||
saveUninitialized: false,
|
saveUninitialized: false,
|
||||||
@@ -30,9 +27,9 @@ const sessionMiddleware = session({
|
|||||||
proxy: true,
|
proxy: true,
|
||||||
cookie: {
|
cookie: {
|
||||||
maxAge: 30 * 24 * 60 * 60 * 1000, // 30 days
|
maxAge: 30 * 24 * 60 * 60 * 1000, // 30 days
|
||||||
secure: true,
|
secure: process.env.NODE_ENV === "production" ? true : false,
|
||||||
httpOnly: true,
|
httpOnly: true,
|
||||||
sameSite: "none"
|
sameSite: process.env.NODE_ENV === "production" ? "none" : "lax"
|
||||||
},
|
},
|
||||||
genid: function () {
|
genid: function () {
|
||||||
return nanoid(21);
|
return nanoid(21);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import "dotenv/config";
|
import "dotenv/config";
|
||||||
import cors from "cors";
|
import cors from "cors";
|
||||||
const corsConfig = { origin: "https://ches.su", credentials: true };
|
|
||||||
|
|
||||||
import express, { Request, Response, NextFunction } from "express";
|
import express, { Request, Response, NextFunction } from "express";
|
||||||
import { createServer } from "http";
|
import { createServer } from "http";
|
||||||
@@ -11,6 +10,11 @@ import { db } from "./db";
|
|||||||
|
|
||||||
import routes from "./routes";
|
import routes from "./routes";
|
||||||
|
|
||||||
|
const corsConfig = {
|
||||||
|
origin: process.env.CORS_ORIGIN || "http://localhost:3000",
|
||||||
|
credentials: true
|
||||||
|
};
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
const server = createServer(app);
|
const server = createServer(app);
|
||||||
|
|
||||||
@@ -40,7 +44,7 @@ io.use((socket, next) => {
|
|||||||
});
|
});
|
||||||
initSocket();
|
initSocket();
|
||||||
|
|
||||||
const port = process.env.PORT || 3000;
|
const port = process.env.PORT || 3001;
|
||||||
server.listen(port, () => {
|
server.listen(port, () => {
|
||||||
console.log(`listening on :${port}`);
|
console.log(`listening on :${port}`);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user