0

there I am trying to store cookies using the post method using nodejs, cookies are not stored on the browser end currently node server is running on localhost 3001 and react server is running on port 3000
the code what I have written mentioned below

Can anybody please suggest me to fix the issue

const express = require("express")

const app= express()
const cookieParser = require('cookie-parser');
const cors = require("cors")
const port = process.env.port || 3001

app.use(cors())


app.use(express.json())

app.post("/names",async(req, res)=>{
    console.log("Ho")
    res.cookie("auth","nagendran")
    res.json({msg:"Hello"})
})

Nagendra N
  • 134
  • 1
  • 7

1 Answers1

0

Edit: Looks like cross origin requests needs quite some work to get cookies right. Take a look here.

Set cookies for cross origin requests

Haijin
  • 2,084
  • 2
  • 12
  • 27