From 0e379f4e158e3d2f39f1812ff8982fdb0f59220a Mon Sep 17 00:00:00 2001 From: Mohan Ki Date: Mon, 27 Jul 2026 16:12:02 +0530 Subject: [PATCH] fix: add cookie-parser middleware to fix 403 on protected routes, add autocomplete to login --- api/server.js | 9 ++++++++- client/src/app/login/page.tsx | 1 + client/src/app/register/page.tsx | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/api/server.js b/api/server.js index 886b0b3..560970b 100644 --- a/api/server.js +++ b/api/server.js @@ -10,8 +10,15 @@ require('dotenv').config(); const app = express(); const port = process.env.PORT || 4001; -app.use(cors({ origin: 'http://localhost:4000', credentials: true })); +const allowedOrigins = [ + 'http://localhost:4000', + 'https://qr.houseofwebsites.ai', + process.env.FRONTEND_URL +].filter(Boolean); + +app.use(cors({ origin: allowedOrigins, credentials: true })); app.use(express.json()); +app.use(cookieParser()); // Routes const authRoutes = require('./routes/auth'); diff --git a/client/src/app/login/page.tsx b/client/src/app/login/page.tsx index 4de17a7..1272016 100644 --- a/client/src/app/login/page.tsx +++ b/client/src/app/login/page.tsx @@ -70,6 +70,7 @@ export default function LoginPage() { onChange={e => setEmail(e.target.value)} className="block w-full px-4 py-3 bg-[#1a1a1a] border border-gray-700 rounded-xl text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition-all" placeholder="admin@ckqr.com" + autoComplete="username" /> diff --git a/client/src/app/register/page.tsx b/client/src/app/register/page.tsx index 41a5660..a252d6f 100644 --- a/client/src/app/register/page.tsx +++ b/client/src/app/register/page.tsx @@ -63,6 +63,7 @@ export default function RegisterPage() { onChange={e => setEmail(e.target.value)} className="block w-full px-4 py-3 bg-[#1a1a1a] border border-gray-700 rounded-xl text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition-all" placeholder="you@company.com" + autoComplete="username" />