mardi 30 juin 2020

Browser Not setting the cookies for fetch api deployed on aws cloudfront

So I am making a request from https://demos.thedomain.com to https://api.thedomain.com with fetch options as:

fetch('https://api.thedomain.com', {
  "body": {"username":"me@asdf.in","password":"qwerty"}",
  "credentials": "same-origin",
  "method": "POST",
  "headers": {
    "Accept": "application/json",
    "Content-Type": "application/json"
  }
})

and the response is:

enter image description here

And the browser doesn't set the cookies. Does anyone knows why this is happening ? The reason I put cloudfront's name in the question is because if I deploy the (exactly same)build to firebase and point route 53 to it, it works perfectly but when I deploy it to S3 for cloudfront and repoint using cloudfront CNAME it fails to set the cookies. I have tried setting secure: true,false both. If any more details is required, just ask.




Aucun commentaire:

Enregistrer un commentaire