简体   繁体   English

在meteor app中如何在cordova config.xml中添加orgin = *?

[英]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. 我需要在config.xml中添加<access origin="*"/>我在浏览器中使用谷歌API工作正常。 But when I run in android device, console throws Uncaught ReferenceError: google is not defined . 但是,当我在Android设备中运行时,控制台抛出Uncaught ReferenceError: google is not defined I think the problem is cordova blocks google api. 我认为问题是cordova阻止google api。 How should I add access origin from meteor? 我该如何从流星添加访问源?

Create a mobile-config.js file in your root meteor project. 在根流星项目中创建mobile-config.js文件。 Read https://docs.meteor.com/#/full/mobileconfigjs 阅读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 这会将以下内容添加到config.xml中

<access origin="*"/>

The following is from: https://docs.meteor.com/#/full/App-accessRule 以下内容来自: https//docs.meteor.com/#/full/App-accessRule

App.accessRule(domainRule, [options]) 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) tel: ,geo: ,mailto: ,sms: ,market:*被允许并在外部启动(手机应用程序或Android上的电子邮件客户端)
  • gap: , cdv: , file: are allowed (protocols required to access local file-system) http://meteor.local/ * is allowed (a domain Meteor uses gap: ,cdv: ,file:是允许的(访问本地文件系统所需的协议) http://meteor.local/ *是允许的(域名Meteor使用
    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 传递给构建过程的服务器的域(或开发模式中的本地IP地址)用于能够联系
    Meteor app server. 流星应用服务器。

Read more about domain patterns in Cordova docs . 阅读有关Cordova文档中域模式的更多信息。

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 . 由于某些可能的攻击 ,默认情况下不再设置所有域和协议()的Meteor 1.0.4访问规则。

Arguments 参数

domainRule String - The pattern defining affected domains or URLs. domainRule String - 定义受影响的域或URL的模式。

Options 选项

launchExternal Boolean - Set to true if the matching URL should be handled externally (eg phone app or email client on Android). launchExternal Boolean - 如果匹配的URL应在外部处理(例如Android上的电话应用程序或电子邮件客户端),则设置为true。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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