DEV Community

Akshat Singhania
Akshat Singhania

Posted on

1

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)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay