且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

带有 woocommerce rest api 的 Ionic3 有发布请求吗?

更新时间:2023-09-08 18:31:46

这就是 CORS 的工作方式(使用跨域请求时).使用 CORS,远程 Web 应用程序(此处为域为 mydomain.org 的应用程序)选择是否可以通过一组特定的标头来处理请求.

This is the way CORS works (when using cross domain requests). With CORS, the remote Web application (here the one with domain mydomain.org) chooses if the request can be served thanks to a set of specific headers.

CORS 规范区分了两个不同的用例:

The CORS specification distinguishes two distinct use cases:

简单请求.如果我们使用 HTTP GET、HEAD 和 POST 方法,则此用例适用.对于 POST 方法,仅支持具有以下值的内容类型:text/plain、application/x-www-form-urlencoded 和 multipart/form-data.

Simple requests. This use case applies if we use HTTP GET, HEAD and POST methods. In the case of POST methods, only content types with the following values are supported: text/plain, application/x-www-form-urlencoded and multipart/form-data.

预检请求.当简单请求"用例不适用时,会发出第一个请求(使用 HTTP OPTIONS 方法)以检查在交叉环境中可以做什么域请求.发送 OPTIONS 请求的不是 Angular2,而是浏览器本身.这与 Angular 无关.

Preflighted requests. When the ‘simple requests’ use case doesn’t apply, a first request (with the HTTP OPTIONS method) is made to check what can be done in the context of cross-domain requests. It's not Angular2 that sends the OPTIONS request but the browser itself. It's not something related to Angular.

更多详情,你可以看看这篇文章:

For more details, you could have a look at this article:

http://restlet.com/blog/2015/12/15/understanding-and-using-cors/