title: Unable to set cookies from backend to frontend when deploying website
body: <p>I'm using Nodejs for my server and Reactjs for my client. In my client, I use axios to perform post/get requests to the server.
  During development, everything is working perfectly fine, data is fetched and cookies are set properly. However, when I deploy my server and client to Heroku and Netlify respectively, the cookies are suddenly not set.</p>
  <p>Here is my server code:</p>
  <pre><code>
  dotenv.config()
  const server = express();
  server.use(cors({origin: &quot;https://frontendname.com&quot;, credentials: true}));
  
  server.use(express.json());
  server.use(express.urlencoded({extended:true}))
  server.use(cookieParser())
  server.use(&quot;/&quot;, fetchData)
  
  server.listen(process.env.PORT, ()=&gt;console.log(`Server listening on PORT ${process.env.PORT}`))
  mongoose.connect(process.env.MONGO_URI, {useNewUrlParser: true, useUnifiedTopology: true}).then( () =&gt; {
      console.log(&quot;connected to mongoose&quot;)
      
  
  }).catch((error) =&gt; console.log(error.message))
  
  </code></pre>
  <p>My server API code</p>
  <pre><code>res.status(201)       .cookie(&quot;accessToken&quot;, accessToken, {domain:&quot;frontendwebsite.com&quot;, httpOnly: true, sameSite: 'strict', path: '/', expires: new Date(new Date().getTime() + 60 * 1000 * 4)})                          .cookie(&quot;refreshToken&quot;, refreshToken, {domain:&quot;frontendwebsite.com&quot;, httpOnly: true, sameSite: 'strict', path: '/', expires: new Date(new Date().getTime() + 60 * 1000 * 96)})                          .json({message: &quot;login verified&quot;, username: req.body.username})                 .send()
  </code></pre>
  <p>My client API code:</p>
  <pre><code>axios.defaults.withCredentials = true
  export const loginAuth = async (credentials) =&gt; { 
      return await axios.post(&quot;https://backendname.herokuapp.com/loginAuth&quot;, credentials).then((res) =&gt; {
          
          return res
      })
  }
  
  
  </code></pre>
  <p>I have a strong feeling its due to the domain name that is not correct in the &quot;res.cookie&quot;. Since in my development when I'm using localhost for both server and client, it works. My client is hosted on Netlify and server is hosted on Heroku. My client has a custom domain name I got from GoDaddy. I used Netlify DNS on that domain name. Any ideas?</p>