first commit
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
const allowedOrigins = process.env.ALLOWED_ORIGINS.split(',').map(origin => origin.trim());
|
||||
|
||||
module.exports = {
|
||||
origin: function(origin, callback) {
|
||||
if (!origin) return callback(null, true);
|
||||
if (allowedOrigins.includes(origin)) {
|
||||
return callback(null, true);
|
||||
}
|
||||
return callback(new Error('CORS: Origin not allowed'), false);
|
||||
},
|
||||
credentials: true
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
const session = require('express-session');
|
||||
const MySQLStore = require('express-mysql-session')(session);
|
||||
|
||||
module.exports = (session) => {
|
||||
return {
|
||||
secret: process.env.SECRET_KEY || 'mhmh4563463fds',
|
||||
resave: false,
|
||||
saveUninitialized: false,
|
||||
store: new MySQLStore({
|
||||
host: process.env.MYSQL_HOST,
|
||||
port: process.env.MYSQL_PORT,
|
||||
user: process.env.MYSQL_USER,
|
||||
password: process.env.MYSQL_PASSWORD,
|
||||
database: process.env.MYSQL_DATABASE
|
||||
}),
|
||||
cookie: {
|
||||
secure: false,
|
||||
httpOnly: true,
|
||||
maxAge: 10 * 60 * 60 * 1000
|
||||
}
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user