简体   繁体   中英

In meteor app how to add orgin=* in cordova config.xml?

I am new to meteor. I am developing mobile app with meteor. I need to add <access origin="*"/> in config.xml I am using google API works fine in browser. But when I run in android device, console throws Uncaught ReferenceError: google is not defined . I think the problem is cordova blocks google api. How should I add access origin from meteor?

Create a mobile-config.js file in your root meteor project. Read https://docs.meteor.com/#/full/mobileconfigjs

You can add an origin wildcard like so.

App.accessRule('*');

This will add the following to your config.xml

<access origin="*"/>

The following is from: https://docs.meteor.com/#/full/App-accessRule

App.accessRule(domainRule, [options])

Set a new access rule based on origin domain for your app. By default your application has a limited list of servers it can contact. Use this method to extend this list.

Default access rules:

  • tel: , geo: , mailto: , sms: , market:* are allowed and launch externally (phone app, or an email client on Android)
  • gap: , cdv: , file: are allowed (protocols required to access local file-system) http://meteor.local/ * is allowed (a domain Meteor uses
    to access app's assets)
  • The domain of the server passed to the build process (or local ip address in the development mode) is used to be able to contact the
    Meteor app server.

Read more about domain patterns in Cordova docs .

Starting with Meteor 1.0.4 access rule for all domains and protocols () is no longer set by default due to certain kind of possible attacks .

Arguments

domainRule String - The pattern defining affected domains or URLs.

Options

launchExternal Boolean - Set to true if the matching URL should be handled externally (eg phone app or email client on Android).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM