i have tried to upload mern project on cpanel but always get cors problem
I have use this function in express js but same problem occurred
app.use(function (req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Headers', 'Origin , X-Requested-With, Content-Type, Accept , Authorization');
res.header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
next();
});
Also tried to use cors package but same error
Express work on poet 5001 and react on port 4000
Any solution can try
2
Answers
thanks all , it was cpanel cors problem and another one i need to add is bcrypt package cause an error so i used bcryptjs library
try npm package cors.
and use it as a middleware in server file .
this means allow all – *