Setting the ROOT_URL on development

I am using a Digital Ocean vps do to my Meteor development.

So when accessing the frontend, I tend to use an actual IP or dev.something.com domain.

Now I would like all emails for user enrollment etc. use the correct domain so I can more actively discuss changes with clients as the project takes shape. However I seem to fail to set the ROOT_URL correctly. In all cases the emails as well as the status messase ‘App running at:’ end up using ‘localhost:3000’ as the root url instead of the ‘dev.something.com:3000’.

Here is what I have tried so far:

Define an environment variable on the vps

In my ~/.bashrc file I added the line:

ROOT_URL="http://dev.something.com:3000

I then ran:

$ source ~/.bashrc
$ echo $ROOT_URL

and confirmed that the correct value was set.

Set the ROOT URL in lib/_globals.js

process.env.ROOT_URL = "http://dev.something.com:3000";
console.log(process.env.ROOT_URL);

Again I confirmed that the relevant value was set correctly by seeing the console.log message.

Set the ROOT URL in impors/startup/paths.js

The path was set the same way as above, the file imported into the main.js file and I checked that the ROOT_URL was actually set through the same console.log message.

Yet in all cases I see localhost in all emails. Is there anything I still need to change or is this just not possible?

I’m using Meteor 1.3.4.1 and adhere to the file structure as suggested by the Meteor Guide.

What’s your deployment strategy?

The only suggestions off the top of my head – in my scripts, I’ve used:

export ROOT_URL=http://mydomain.com:3000

And in my files, the path of my startup.js is: imports/startup/server/startup/startup.js

Also, my code is wrapped in the startup method, as such:

Meteor.startup( function() {
  // Set some environment variables...

  process.env.ROOT_URL = 'http://mydomain.com:3000';
});

I deploy with mupx on a selfhosted server.
I don’t have any issue when deploying that way and specifying the domain in the configuration file.

The issue here is when I’m working locally on my development VPS.
My current client is quite happy for me to look at different options for UI components straight in Meteor, so I end up just changing a setting as Meteor is running on the VPS.
At the next meeting the largest part of this presentation is the User Management which will send enrollment emails. All of these are sent out as localhost.

I’m setting my ROOT_URL as you suggest. It’s only in a startup folder but I know it executes as I log messages. Yet the emails are still going out as localhost.

So wait, are you actually deploying, or just running Meteor? This thread should shed some light on what’s going on: https://github.com/meteor/meteor/issues/5973

Is it the account emails you are having trouble wth? You can override the default site name using options here: http://docs.meteor.com/api/passwords.html#Accounts-emailTemplates

1 Like