0

This is the first time I`m toying with PhoneGap, so I actually never needed Cross Origin Resource Sharing (CORS) before.

It is by default blocked, and the options I found in the web are either hacks or insecure. My question is: What is the best or proper way to accomplish server integration using PhoneGap?

Bear in mind:

  • I need session control serverside to keep the user logged in
  • The request is coming from a file in PhoneGap's webview so origin = null
  • I'm using PHP serverside and have full control over it
  • <access origin="*" /> is already added to config.xml (it enables me to reach out for the server, but doesn't guarantee it will respond to a cross-origin request)

A long search on the web lead me to:

Access-Control-Allow-Origin *
Access-Control-Allow-Credentials true

But I understood they're rather unsafe, specially combined. I could save the user session ID locally, but that seems hacky and unsafe.

There's also JSONP to the rescue, but that also seems hacky, unsafe and won't persist my session ID.

I could use a proxy server, but that seems far from optimal and as I understand it'll be hard to prevent an attacker to not use this same proxy server to perform the same operations.

Bruno
  • 31
  • 4

1 Answers1

0

Hi you can disable security to browser and use it. Please find the link for disabling security for chrome.

[Disable same origin policy in Chrome

Community
  • 1
  • 1
Sunand
  • 683
  • 4
  • 9