所有POST请求的一个选项 [英] one OPTIONS for all POST requests

查看:70
本文介绍了所有POST请求的一个选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于所有后续的 POST 请求,是否可以有一个 OPTIONS 请求。

Is there any way to have one OPTIONS request for all the subsequent POST requests.

应用程序在需要时通过 POST 请求与服务器进行通信。有许多无关的 POST 请求的发生,对于每个 POST 请求,都会触发一个 OPTIONS 来确保 CORS 。我们能否为所有这些 POST 请求提供一个选项

The application communicates with the server by means of POST requests whenever required.There are many unrelated POST requests happening and for each POST request one OPTIONS is triggered to ensure CORS.Can we have one OPTIONS for all these POST requests.

推荐答案

查找此处,我相信您可以通过将 Access-Control-Max-Age标头设置任意长时间来完成此操作。此字段确定在需要发送其他OPTIONS请求之前,将飞行前OPTIONS请求的结果缓存了多长时间,因此,通过扩展它可以限制发送OPTIONS请求的频率。

Looking here, I believe you can accomplish this by setting the "Access-Control-Max-Age" header for an arbitrarily long duration of time. This field determines how long the results from the pre-flight OPTIONS request are cached for before an additional OPTIONS request needs to be sent, so by extending it you can limit how often OPTIONS requests are sent.

这篇关于所有POST请求的一个选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆