跨域HTTP请求 [英] Cross domain HTTP requests

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

问题描述

我试图将带有某些参数的HTTP POST请求发送到第三方API,该API会返回数据.我正在尝试使其正常工作,但是遇到了问题.在研究解决此问题的过程中,我开始阅读有关跨域HTTP请求的信息.关于如何执行跨域HTTP请求以及为什么某些方法好而又有些差的站点之间,存在一个接一个的站点.但是,所有内容的编写方式都表明跨域请求不是完成"的事情.

I was trying to send an HTTP POST request with certain parameters to a third party API which would return data. I was trying to it to work but was having issues. As part of my research into resolving the problem I started to read about cross domain HTTP requests.There were site after site on how to perform cross domain HTTP requests and why some methods were good and others bad. However, it was all written in a way that suggested that cross domain requests weren't the 'done' thing.

现在,请原谅我的无知,因为我对此并不陌生,但这使我有些困惑.当然,跨域HTTP请求是HTTP请求的重点吗?有人编写了一个脚本,可以向该脚本发送HTTP请求(具有适当的凭据以授权访问),并且该脚本可以与基础应用程序对话,根据请求者发送的参数进行一些处理,并返回一些数据.

Now, please excuse my ignorance as I'm very new to all this, but this confused me somewhat. Surely cross domain HTTP requests are the whole point of HTTP requests? Someone writes some script to which one can send HTTP requests (with the proper credentials to authorise access) and the script can talk to the underlying application, do some processing based on the parameters sent by the requester and return some data.

我当然知道您可以在自己的网站(来自同一域)中拥有脚本,可以向其发送信息并获得返回的结果,例如验证脚本.

Of course I know you can have scripts in your own website (from the same domain) to which you can send information and get results returned, such as validation scripts.

本质上,我的问题是:跨域HTTP请求不是规范要求吗?".

In essence my question is: "Are cross domain HTTP requests not the norm?".

我很欣赏我的问题更多是讨论,而不是有特定答案的问题,但我很感谢可以提供的任何帮助.

I appreciate that my question is more of a discussion rather than a problem with a specific answer but I'd appreciate any help that can be offered.

推荐答案

简短的回答是正常的.您可以在一个项目的不同域上进行api和授权,并从前端的另一个域中使用它.为什么会异常?

Short answer is it's normal. You can make api, authorization on different domains for one project and consume it from another domain that just frontend. Why it can be abnormall?

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

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