Cordova Ajax requests Cross-domain problem collation

Source: Internet
Author: User
Tags error code eval

first, by default, Cordova cannot directly use Ajax to request access to other data in the page.

Exception 1:

Ripple.js:51 refused to connect to ' Http://localhost:59201/api/category/getlistbyparent? Projectcode=lc_app_v1 ' because it violates the following Content Security Policy directive: "Default-src ' self ' data:gap: Https://ssl.gstatic.com ' Unsafe-eval ' ". Note that ' connect-src ' was not explicitly set, so ' default-src ' is used as a fallback.

Solution:

page-level configuration , allowing the page's connect to request the other data

Set the Content-security-policy CONNECT-SRC *;

Examples are as follows:

<meta http-equiv= "Content-security-policy" content= "default-src ' self ' data:gap:https://ssl.gstatic.com ' Unsafe-eval '; Style-src ' self ' unsafe-inline '; MEDIA-SRC *;CONNECT-SRC *; " >

Exception 2:

ripple.js:51 OPTIONS Http://localhost:4400/ripple/xhr_proxy?tinyhippos_apikey=ABC&tinyhippos_rur...//localhost %3A59201/API/CATEGORY/GETLISTBYPARENT%3FPROJECTCODE%3DLC_APP_V1 net::err_connection_refused

and exception 3 issues with Internet Server error:

Error code Is:xhr_proxy?tinyhippos_apikey=abc&tinyhippos_rurl=http%3a//localhost%3a30673/ap? i/user/Get% 3Fjson rippleapi.herokuapp.com Status code:500 Internal Server Error I ' am getting data from my localhost post adress:local Host:30673/api/user/get '; It is the working well in browser. And getting data from Localhost:30673/api/user/get. Ripple it tries to get data from there:xhr_proxy?tinyhippos_apikey=abc&tinyhippos_rurl=http%3a//localhost% 3a30673/api/u? Ser/get%3fjson rippleapi.herokuapp.com

Solution:

Ripple Configuration

Ipple settings There is a cross Domain Proxy in the upper right corner, with three choices, Disabled, local, and remote, which can be literally seen to be disabled, locally and remotely accessible, if you are accessing the native API. It is generally set to disabled. If you access the remote host's API, it is generally set to either remote or disabled.


Exception 4: Common Ajax cross-domain issues, this is primarily server-side configuration, can be consulted: Enable ASP. WEBAPI support for JSONP and Cors cross-domain access


Related article: http://www.it165.net/pro/html/201608/74401.html


More:

Cordova Config configuration webview full screen browsing

Cordova-plugin-themeablebrowser plug-in use collation

Cordova page Load External screen picture failed, refused to load the image

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.