我正在将Heroku 和firebase 用于 MONGODB 的后端和前端数据库当我在数据库中正确注册其存储数据但登录时它没有从数据库中获取数据.....请告诉我我做错了什么
前端
const res = await fetch(http://wu.herokuapp.com/signin", {
method: "POST",
headers: {
"Content-Type": "application/json" },
body: JSON.stringify({
email,
password,
}),
});
后端
const corsOptions = {
origin: "https://wu.firebase/",
methods: "GET,HEAD,POST,PATCH,DELETE,OPTIONS",
credentials: true,
allowedHeaders: "Origin,Content-Type, Authorization, X-Requested-With",
}
router.use(cors({origin:true,credentials: true}));
router.options('*', cors())
router.use(express.json());
router.use(express.urlencoded({extended: false}));
router.post("/signin",cors(corsOptions), async (req, res) => {
try {
let token;
const { email, password } = req.body;
if (!email || !password) {
return res.status(400).json({ error: "Plz Filled the data" });
}
const userLogin = await User.findOne({ email: email });
if (userLogin) {
const isMatch = await bcrypt.compare(password, userLogin.password);
token = await userLogin.generateAuthToken();
res.cookie("jwtoken", token, {
expires: new Date(Date.now() + 100000000),
httpOnly: false,
},