Meteor.absoluteUrl() does not include the port


Meteor.absoluteUrl() does not include the port
so my app breaks on localhost:3000 when trying to generate a pdf file
because the port is missing.

How can I address this?


1 Like

I see the port on both server and client execution of Meteor.absoluteUrl() – are you sure this is the issue?

Thanks for the answer.
Yes, I am sure.
I wonder why it is not including the port number for me?

Are you setting the --port flag when you run meteor?

No, I am not.
which is the right port number ?
Or the most popular number?
3000 ?

I do not set the port when running meteor, but I have to load the app at 3000 port
so if meteor is using that port, should it not use it for absoluteUrl()

I just spun up a new meteor project, ran meteor without the --port flag, and still I see this:

If you run console.log(Meteor.absoluteUrl());, what do you see?

I see http://localhost/

Are you setting ROOT_URL somewhere? On the server, try: console.log(process.env.ROOT_URL);

1 Like

process.env.ROOT_URL is http://localhost
even when I run the app with the following command
meteor --port 3000 --settings staging/settings.json

Yeah, so you (or a package, etc) is setting the ROOT_URL environment variable.

You can set the variable with: export ROOT_URL=http://localhost:3000 before running meteor.

1 Like

Yes, you are right.
In my case
set ROOT_URL=http://localhost:3000
because I use windows

1 Like