gpt4 book ai didi

javascript - 在 meteor 应用程序中如何在 cordova config.xml 中添加 orgin=*?

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:05:22 25 4
gpt4 key购买 nike

我是 meteor 的新手。我正在用 meteor 开发移动应用程序。我需要添加 <access origin="*"/>在 config.xml 中,我正在使用谷歌 API 在浏览器中工作正常。但是当我在 android 设备中运行时,控制台会抛出 Uncaught ReferenceError: google is not defined .我认为问题是 cordova 阻塞了 google api。我应该如何添加来自 meteor 的访问源?

最佳答案

在您的根 meteor 项目中创建一个 mobile-config.js 文件。阅读https://docs.meteor.com/#/full/mobileconfigjs

您可以像这样添加一个原始通配符。

App.accessRule('*');

这会将以下内容添加到您的 config.xml

<access origin="*"/>

以下内容来自: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).

关于javascript - 在 meteor 应用程序中如何在 cordova config.xml 中添加 orgin=*?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29279287/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com