diff --git a/admin-client/src/components/AddCourse.jsx b/admin-client/src/components/AddCourse.jsx index b1548f6..3215803 100644 --- a/admin-client/src/components/AddCourse.jsx +++ b/admin-client/src/components/AddCourse.jsx @@ -10,7 +10,7 @@ function AddCourse() { const [image, setImage] = useState(""); const [price, setPrice] = useState(0) - return
+ return
{ }); router.post('/login', async (req, res) => { - const { username, password } = req.headers; + const { username, password } = req.body; const admin = await Admin.findOne({ username, password }); if (admin) { const token = jwt.sign({ username, role: 'admin' }, SECRET, { expiresIn: '1h' }); diff --git a/server/routes/user.js b/server/routes/user.js index a38e05f..c17ed5d 100644 --- a/server/routes/user.js +++ b/server/routes/user.js @@ -17,7 +17,7 @@ const router = express.Router(); }); router.post('/login', async (req, res) => { - const { username, password } = req.headers; + const { username, password } = req.body; const user = await User.findOne({ username, password }); if (user) { const token = jwt.sign({ username, role: 'user' }, SECRET, { expiresIn: '1h' });