请求在api上生成两个请求-错误 [英] Request generate two requests on api - error
问题描述
我有一个api,我通过在线商店进行消费,但是该站点发出的请求中有问题。我总是收到两个请求,一个使用OPTION,另一个使用POST,这是因为每次执行第一个请求或另一个请求时,API最终都被洗了。有人可以帮我吗? ;
我之前遇到过相同的问题,这是预期的行为与
然后,您将在服务器端收到两个请求,但在前端只有一个回调响应,所以我的建议是在服务器端和前端验证第一个 OPTION 请求结束时,您只会收到一个回调响应。
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 }));
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.
这篇关于请求在api上生成两个请求-错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!