Jean-Pierre Carvalho
Jean-Pierre Carvalho

Reputation: 44

Request generate two requests on api - error

I have an api in which I consume through an online store but I have a problem in the requests that the site makes. I always get two requests, one with OPTION and the other with POST, it happens that the api ends up being shuffled when I perform every time I make the first request or another one different. Can someone help me?

app.use(cors({ origin:true, credentials: true, preflightContinue: true }));

Upvotes: 0

Views: 109

Answers (1)

Abel Valdez
Abel Valdez

Reputation: 2408

I had the same issue before and it's an expected behavior related with CORS

Then you will have two request on server side but just one callback response on front-end, so my recommendation is to validate the first OPTION request on server side and in the front-end you will get just one callback response.

Upvotes: 1

Related Questions