On the galaxy.meteor.com overview page for my app, it nicely states which version (iteration?) has been deployed by galaxy…
Version 11 Deployed Yesterday at 12:09pm by …
Is there a programatic way I can obtain this number from my Meteor server code? It would be useful to quickly know I am not at ‘latest’ inside my deployed code.
@williamli That may seem creative, but that is an incredibly insecure server side method that should not be installed in any application. Environment variables are often used to store secure information which should not be revealed to the client. In the case of GALAXY_APP_VERSION_ID, the value is relatively harmless. However, if someone were do to:
…They will have the username and password to your Mongo database.
Please, think about security. There is no need to make this server method have access to every environment variable when it could just return the version number.
For the most part, this code shouldn’t really be necessary at all since Galaxy handles the updating of the server to the latest code automatically, and the Meteor client-side reloads itself to get the latest version when the server has been updated.
Is there any option to do this in a more secure way? E.g. get the Galaxy version at the server side and pass only this information (version number) to the client…to have it displayed at the UI. Would be pretty helpful when testing with other people like end-users - who are not involved in the dev process but have to qualify bug reports.
Sure, just change the above method so it cannot return any environment variable from the server, instead opting for only the single environment variable that’s needed. For example, consider a server method that does just:
@abernix: Thank you very much for your reply. I tried several times but had no luck.
After checking the docs, etc. and other code examples I thought it makes sense to put the method you mentioned into “server/main.js”, code is like this:
import {Meteor} from 'meteor/meteor';
Meteor.methods({
getCurrentGalaxyAppVersionId() {
console.log("#CUSTOMLOG# Your Galaxy version is " + process.env['GALAXY_APP_VERSION_ID']);
return process.env['GALAXY_APP_VERSION_ID'];
}
});
Above log statement works fine, by the way.
Additionally I placed the client code in “imports/ui/body.js”, as I want to call
the method from body.html file:
import { Meteor } from 'meteor/meteor';
import { Template } from 'meteor/templating';
[..]
Template.body.helpers({
getCurrentGalaxyAppVersionId: function () {
Meteor.call('getCurrentGalaxyAppVersionId');
}
});