0

I'm using React on the Frontend and NestJS on the backend.

I've created a JWT token which i've attached to a cookie, the cookie is being sent to the client after client successfully register with the DB.

Using Postman I can see the mentioned cookie but don't know how to access it in the frontend.

See code below, Please advice.

FrontEnd

const requestFormSubmition = async () : Promise<any> => {
    const response = await axios.post('http://localhost:3006/auth/login', {
        ...formData
    },
    {
        headers : {
            "Access-Control-Allow-Headers": "Accept"
        }
    })
    // const allResponse = response.headers;
    console.log(response);
}

Backend

return response.cookie("Autorization-token", data.access_token).json();

Cors options on the backend

  const app = await NestFactory.create(AppModule, { cors: {
    "origin": "*",
    "methods": "GET,HEAD,PUT,PATCH,POST,DELETE",
    "exposedHeaders" : "*",
    "allowedHeaders": "*",
  }
  });
  
  app.use(cookieParser());

Postman result

enter image description here

0 Answers0