diff --git a/History.md b/History.md index 295b977fec..a71f15b9be 100644 --- a/History.md +++ b/History.md @@ -325,6 +325,10 @@ * Fix `Error: Can't render headers after they are sent to the client`. #4253 #4750 +* `Meteor.settings.public` is always available on client and server, + and modifications made on the server (for example, during app initialization) + affect the value seen by connecting clients. #4704 + ### Windows * Increase the buffer size for `netstat` when looking for running Mongo servers. diff --git a/packages/meteor/client_environment.js b/packages/meteor/client_environment.js index 4e894e0e0f..9f8be953b5 100644 --- a/packages/meteor/client_environment.js +++ b/packages/meteor/client_environment.js @@ -25,7 +25,7 @@ Meteor = { if (typeof __meteor_runtime_config__ === 'object' && __meteor_runtime_config__.PUBLIC_SETTINGS) { /** - * @summary `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 you don't provide any settings, `Meteor.settings` will be an empty object. 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. + * @summary `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. * @locus Anywhere * @type {Object} */ diff --git a/packages/meteor/server_environment.js b/packages/meteor/server_environment.js index a5e186182c..b0c7cbb5bf 100644 --- a/packages/meteor/server_environment.js +++ b/packages/meteor/server_environment.js @@ -20,7 +20,11 @@ if (! Meteor.settings.public) { Meteor.settings.public = {}; } -// Push a subset of settings to the client. +// Push a subset of settings to the client. Note that the way this +// code is written, if the app mutates `Meteor.settings.public` on the +// server, it also mutates +// `__meteor_runtime_config__.PUBLIC_SETTINGS`, and the modified +// settings will be sent to the client. if (typeof __meteor_runtime_config__ === "object") { __meteor_runtime_config__.PUBLIC_SETTINGS = Meteor.settings.public; }