DEV Community

Akshat Singhania
Akshat Singhania

Posted on

express session cookie not working , react , axios

To make it work simply do

import axios from "axios";

const Axios = axios.create({
  baseURL:
    process.env.NODE_ENV === "development"
      ? process.env.REACT_APP_DEV_SERVER_URL
      : process.env.REACT_APP_SERVER_URL,
});
Axios.defaults.withCredentials = true;

export default Axios;
Enter fullscreen mode Exit fullscreen mode

or
just

import axios from "axios";

axios.defaults.withCredentials = true;
Enter fullscreen mode Exit fullscreen mode

It makes axios store cookies

Thanks for reading, hearts ❤️ if you liked it and unicorns 🦄 if you loved it, follow if you wanna read more awesome blogs

Top comments (0)