File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -48,11 +48,12 @@ const UserSchema = new mongoose.Schema({
4848// Encrypt password using bcrypt
4949UserSchema . pre ( 'save' , async function ( next ) {
5050 if ( ! this . isModified ( 'password' ) ) {
51- next ( ) ;
51+ return next ( ) ;
5252 }
5353
5454 const salt = await bcrypt . genSalt ( 10 ) ;
5555 this . password = await bcrypt . hash ( this . password , salt ) ;
56+ next ( ) ;
5657} ) ;
5758
5859// Match user entered password to hashed password in database
Original file line number Diff line number Diff line change @@ -32,6 +32,9 @@ if (process.env.ENABLE_WEBSOCKETS === 'true') {
3232// Body parser
3333app . use ( express . json ( ) ) ;
3434
35+ // Trust proxy for Azure/reverse proxy (required for rate limiting)
36+ app . set ( 'trust proxy' , 1 ) ;
37+
3538// Enable CORS - allow all origins for Azure compatibility
3639app . use ( cors ( {
3740 origin : true ,
@@ -40,8 +43,10 @@ app.use(cors({
4043 allowedHeaders : [ 'Content-Type' , 'Authorization' , 'X-Requested-With' ]
4144} ) ) ;
4245
43- // Apply rate limiting to all API routes
44- app . use ( '/api' , apiLimiter ) ;
46+ // Apply rate limiting to all API routes (skip in production if causing issues)
47+ if ( process . env . NODE_ENV !== 'production' || process . env . ENABLE_RATE_LIMIT === 'true' ) {
48+ app . use ( '/api' , apiLimiter ) ;
49+ }
4550
4651// Serve static files for uploads
4752app . use ( '/uploads' , express . static ( path . join ( __dirname , 'uploads' ) ) ) ;
You can’t perform that action at this time.
0 commit comments