Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 217
Ramesh Murugesan Avatar asked Mar 26 '15 13:03

Ramesh Murugesan


People also ask

Where do I find config xml?

Each WebLogic Server domain contains a central configuration file called the config. xml, which is stored in the DOMAIN_HOME\config directory. Both the Admin Server and the Managed Servers derive their run-time configuration information from the config.

Where is config xml in cordova?

The Cordova config. xml file is the global configuration file of the application. The Cordova configuration file is a mandatory XML file that contains application metadata, and is stored in the root directory of the app.

How do I add a plugin to config xml cordova?

When adding plugins or platforms, use the --save flag to add them to config. xml. Ex: cordova platform add android --save. Existing projects can use cordova plugin save and cordova platform save commands to save all previously installed plugins and platforms into your project's config.

What are the elements in config xml file of cordova?

The name of the app that we specified when creating the app. Description for the app. Author of the app. The app's starting page.


1 Answers

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 (e.g. phone app or email client on Android).

like image 196
ethree Avatar answered Sep 20 '22 15:09

ethree