Meteor - What is the purpose of "ROOT_URL" and to what should it be defined?

meteor, nginx

Solution

The `ROOT_URL` environment variable should be set to the URL that clients will be accessing your application with. So in your case, it would be `http://gentlenode.com` or `https://gentlenode.com`.

The `ROOT_URL` environment variable is read by `Meteor.absoluteUrl`, which is used in many (core) packages. Thus, setting `ROOT_URL` may be a requirement if you use these packages. `spiderable` is one such package.

// Line 62 of spiderable_server.js
var url = Spiderable._urlForPhantom(Meteor.absoluteUrl(), req.url);

Problem

I'm getting some problems to make spiderable work with PhantomJS on my Ubuntu server. I saw this troubleshooting on Meteorpedia: Ensure that the ROOT_URL that your Meteor server is configured to use is accessible from the server itself. (Since v0.8.1.3[1]) I think that this could be a possible answer to why it is not working. What is exactly the purpose of this environment variable? My application is publicly accessible on `http://gentlenode.com/` but my `proxy_pass` on nginx is set to `http://gentlenode/`. ``` # HTTPS Server server { listen 443; server_name gentlenode.com; # ... location / { proxy_pass http://gentlenode/; proxy_http_version 1.1; # ... } } ``` Should I set `ROOT_URL` to `http://gentlenode.com/`, to `http://gentlenode/` or to `http://localhost/`? You can find my nginx configuration here: https://gist.github.com/LeCoupa/9877434

Original source