Answer the question
In order to leave comments, you need to log in
PhoneGap + CORS: how to authorize with an AJAX request?
Wrote the framework of the application. I'm running with Ripple (not a chrome extension, but an npm package).
My site authorizes with a POST request, returns JSON.
If I run this in the emulator, I need a cross-domain request, as well as a number of headers. In particular - to issue the correct origin, tk. the address is localhost:4400 and the cookies work fine.
If I run it on the device, then origin is: file:// , and cookies do not work.
Question: how can I authorize the device so that it accepts cookies and then uses them in subsequent requests?
Answer the question
In order to leave comments, you need to log in
Apparently all the data needs to be stored in localStorage, and not in cookies. There was an article on Habré where authorization was done: habrahabr.ru/post/181610
do not use cookies to store data, because they are for the exchange of some kind of state between the client and the server. On the client you have LocalStorage or SessionStorage.
As for CORS - you can run chrome with --disable-web-security if you break CORS on the server, which does not take much time.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question