From 7c19edbdb3e2b26fd874f8e356f4a9df85902617 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 16 Apr 2026 17:41:53 +0000 Subject: [PATCH] Improve security, performance, and code quality across the stack Security: - Add in-memory rate limiter middleware (100 req/15 min per IP) on all /api routes - Restrict CORS to configured allowed origins with explicit method/header allowlist - Set X-Content-Type-Options, X-Frame-Options, X-XSS-Protection response headers - Enforce 10 KB JSON body size limit to block large-payload attacks - Validate and restrict file uploads to JPEG/PNG/WebP/GIF, max 5 MB - Validate MongoDB ObjectId format before hitting the DB in getBlog - Strip internal error objects from all 500 responses (no stack traces to client) - Fix Flask running with debug=True; now reads FLASK_DEBUG env var (defaults off) Validation & correctness: - Add input length and format validation in all four controllers - Add duplicate-email check in newsletter subscription (returns 409) - Add model-level maxlength constraints to match controller limits - Add lowercase + unique index to Newsletter email field - Fix newsletter controller returning wrong "Contact form" success message - Replace placeholder getContact / getNewsletter stubs with 405 responses Performance: - Add cursor-based pagination (page/limit) to getAllBlog and getAllFeedback - Run DB count and find queries concurrently with Promise.all - Fire email sends asynchronously so they don't block HTTP responses Frontend: - Remove duplicate AOS CSS import (was loaded 3 times) - Fix broken backslash path in preloader.css link - Remove JS comment from