fix: CORS for localhost:3000, login with username or email, favicon

Made-with: Cursor
This commit is contained in:
Talal Sharabi
2026-03-12 15:35:36 +04:00
parent 4c139429e2
commit 854a42980d
6 changed files with 27 additions and 12 deletions

View File

@@ -18,7 +18,18 @@ export const config = {
},
cors: {
origin: process.env.CORS_ORIGIN?.split(',') || ['http://localhost:3000'],
origin: (() => {
const envOrigins = process.env.CORS_ORIGIN?.split(',').map((o) => o.trim()).filter(Boolean);
const defaults = ['http://localhost:3000', 'http://localhost:5173'];
const origins = envOrigins?.length ? envOrigins : defaults;
// In development, always allow both common dev server origins
if (process.env.NODE_ENV !== 'production') {
['http://localhost:3000', 'http://localhost:5173'].forEach((o) => {
if (!origins.includes(o)) origins.push(o);
});
}
return origins;
})(),
},
upload: {

View File

@@ -30,7 +30,7 @@ router.post(
router.post(
'/login',
[
body('email').isEmail().withMessage('البريد الإلكتروني غير صالح'),
body('email').trim().notEmpty().withMessage('البريد الإلكتروني أو اسم المستخدم مطلوب'),
body('password').notEmpty().withMessage('كلمة المرور مطلوبة'),
],
validate,