R
R
rubyroidas2015-03-25 13:23:43
JavaScript
rubyroidas, 2015-03-25 13:23:43

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

2 answer(s)
E
Evgeny Kalibrov, 2015-03-25
@rework

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

S
Sergey, 2015-03-25
Protko @Fesor

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 question

Ask a Question

731 491 924 answers to any question