Axios withCredentials 1

Axios withCredentials

const corsConfig = {
  origin: true,
  credentials: true,
};

app.use(cors(corsConfig));
app.options('*', cors(corsConfig));

Here is what the above code is Doing:
1. We’re importing the cors package.
2. We’re creating a corsConfig object that contains the origin, credentials, and methods that we want to allow.
3. We’re using the cors middleware on our Express app, passing in our corsConfig object.
4. We’re using the cors middleware on our Express app’s options method, passing in our corsConfig object.

Similar Posts