@@ -31,11 +31,13 @@ declare global {
3131
3232const app = express ( ) ;
3333app . use ( express . json ( ) ) ;
34- const whitelist = [ 'https://finno.aryanbachchu.tech' , 'http://localhost:5173' , 'https://api.finno.aryanbachchu.tech' ] ;
34+ const whitelist = [ 'https://finno.aryanbachchu.tech' , 'http://localhost:5173' ]
3535
3636app . use ( cors ( {
3737 origin : function ( origin , callback ) {
38- if ( origin && whitelist . indexOf ( origin ) !== - 1 ) {
38+ if ( ! origin ) return callback ( null , true ) ;
39+
40+ if ( whitelist . indexOf ( origin ) !== - 1 ) {
3941 callback ( null , true )
4042 } else {
4143 callback ( new Error ( 'Not allowed by CORS' ) )
@@ -47,14 +49,14 @@ app.use(session({
4749 secret : process . env . SESSION_SECRET ! ,
4850 resave : false ,
4951 saveUninitialized : false ,
50- cookie : { httpOnly : true , sameSite : "lax" } ,
52+ cookie : { httpOnly : true , sameSite : "lax" , secure : true , maxAge : 24 * 60 * 60 * 1000 } ,
5153} ) ) ;
5254app . use ( "/api/v1" , mainRouter ) ;
5355
5456async function main ( ) {
5557 console . log ( `${ process . env . DB_URL } /${ process . env . DB_NAME } ?replicaSet=mongoSet` ) ;
5658 await mongoose . connect ( `${ process . env . DB_URL } /${ process . env . DB_NAME } ?replicaSet=mongoSet` , {
57- serverSelectionTimeoutMS : 20000
59+ serverSelectionTimeoutMS : 40000
5860 } ) ;
5961 console . log ( 'db connected' ) ;
6062
0 commit comments