Cross domain HTTP requests

喜夏-厌秋 提交于 2021-02-08 06:33:08

问题


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.

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.

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.


回答1:


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?



来源:https://stackoverflow.com/questions/34879977/cross-domain-http-requests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!