fix: CORS for localhost:3000, login with username or email, favicon
Made-with: Cursor
This commit is contained in:
@@ -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: {
|
||||
|
||||
@@ -30,7 +30,7 @@ router.post(
|
||||
router.post(
|
||||
'/login',
|
||||
[
|
||||
body('email').isEmail().withMessage('البريد الإلكتروني غير صالح'),
|
||||
body('email').trim().notEmpty().withMessage('البريد الإلكتروني أو اسم المستخدم مطلوب'),
|
||||
body('password').notEmpty().withMessage('كلمة المرور مطلوبة'),
|
||||
],
|
||||
validate,
|
||||
|
||||
Reference in New Issue
Block a user