gpt4 book ai didi

node.js - Meteor 1.3及配置

转载 作者:太空宇宙 更新时间:2023-11-04 00:43:32 27 4
gpt4 key购买 nike

我有一个简单的问题。当您使用node + webpack时,您可以轻松配置任何您想要的内容。

例如,我可以在我的应用程序模块的配置默认路径中写入。

我如何在 Meteor 1.3 中做到这一点?他们有一些配置文件,例如 Webpack 吗?

最佳答案

Meteor 应用程序可以存储 API key 或全局设置等配置选项。提供此配置的一个简单方法是使用 Meteor 应用程序根目录中的 settings.json 文件。键/值对仅在服务器上可用,但您可以使用 public 提供对设置的公共(public)访问:

settings.json

{
"privateKey": "privateValue",
"public": {
"publicKey": "publicValue"
}
}

这些值可在您的应用中使用 Meteor.settings 获得。

来自完整的 Meteor 文档:

Meteor.settings contains deployment-specific configuration options. You can initialize settings by passing the --settings option (which takes the name of a file containing JSON data) to meteor run or meteor deploy. When running your server directly (e.g. from a bundle), you instead specify settings by putting the JSON directly into the METEOR_SETTINGS environment variable. If the settings object contains a key named public, then Meteor.settings.public will be available on the client as well as the server. All other properties of Meteor.settings are only defined on the server. You can rely on Meteor.settings and Meteor.settings.public being defined objects (not undefined) on both client and server even if there are no settings specified. Changes to Meteor.settings.public at runtime will be picked up by new client connections.

TheMeteorChef's Blog 上也可以找到一篇不错的文章。

关于node.js - Meteor 1.3及配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35786006/

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