问题
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