Answer the question
In order to leave comments, you need to log in
What about cross-domain ajax requests?
Good afternoon! There is a project on django as well as two servers that give information about the status of networks and servers. Almost all requests come from js, that is, from the client, the servers are on the same domain, but on different ports. Right now everything is running with errors like Single Origin Policy prohibits reading remote resource on (Reason: CORS header 'Access-Control-Allow-Origin' is missing). Actually, there are two ways, either to do proxying through django, that is, all requests will go through python (not a very good option). Or finish js with some kind of library for such requests. Actually, your opinion is interesting, which is better, and if you take the second option, which library is better? Or is it possible to get by with adding headers altogether? ps The jquery library is also connected
Answer the question
In order to leave comments, you need to log in
Add headers at the web server level, specifying the host from which you pull the data as trusted. :)
score on cross-domain at the browser level and lead all requests from js to one server. let this server provide interactions
> make proxying through django, that is, all requests will go through python (not a very good option).
Why not very good?
If there is MVC, then simply create a new Action in the controller, inside which you make a request, and return the response to this request. Everything.
> Or finish js with some kind of library for such requests
. Where did you see this?
Libraries are just wrappers for pure JS that make it easier to work with but don't add any new functionality.
What is impossible on raw JS, there are no libraries for that
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question