禁止Angular CORS中的OPTIONS请求 [英] Suppress OPTIONS Requests in Angular CORS

查看:128
本文介绍了禁止Angular CORS中的OPTIONS请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我预见到使用Angular进行的CORS调用确实可以工作,是否可以抑制OPTIONS调用,以免它们在生产中不必要地继续发生?

If I have foreknowledge that CORS calls made with Angular will, indeed, work, can I suppress the OPTIONS calls so that they don't continue needlessly occurring in production?

推荐答案

此OPTIONS请求告诉客户端是否允许CORS请求;对于这些请求,可以执行哪些方法(GET,POST,PUT等).

This OPTIONS request tells the client if a CORS request will be allowed; and, for those requests, which methods (GET, POST, PUT, etc.) can be executed.

如果仅实施简单方法:GET/POST/HEAD.

According to W3c options call is not required if you are implementing only simple methods: GET/POST/HEAD.

因此,如果您要设置Access-Control-Allow-Methods,请尝试*将其更改为"GET,POST"并根据标准(如果遵循浏览器),则浏览器无需触发选项打电话.

So where you set your Access-Control-Allow-Methods if it is * try changing it to "GET,POST" and based on the standard (if the browser follows), your browser doesn't need to fire the options call.

这篇关于禁止Angular CORS中的OPTIONS请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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