I
I
identifier classname2017-09-20 09:44:40
JavaScript
identifier classname, 2017-09-20 09:44:40

How to access a REST server from a web page that has a different origin?

Let's say there is a page open on a local server, or the same page as a mobile application.
How to contact the web server from it to send and receive data.
XHR is not good because it only works on the same domain.
Websockets are fine, but it's harder to implement.
Through forms?
How is it usually done?
I do not have one site from which I need to access the api of another site
I have a spherical web page in a vacuum from which I want to work with my server api
For example, I found the Porthole library - will this solve my problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly, 2017-09-20
@vshvydky

Usually, cors is expanded on the server, the allow origin is made to those domains that are considered trusted. The browser without this check considers such links as foreign and cuts for safety. If we are talking about a production project, then you should not castigate. If the server is not yours, you should proxy the request through your server.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question