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