Remove port from Router url Helpers?

My Endpoint is configured like this:

config :my_web, MyWeb.Endpoint,
    url: [host: "mydomain.com", scheme: "https"],
    http: [port: 5000]

I am serving the phoenix app at localhost port 5000, and have nginx as https server in front of it.

Currently pages load correctly and everything. However, I’m trying to use the MyWeb.Router.Helpers.url helpers and instead of
https://mydomain.com
it is returning
https://mydomain.com:5000

How can I get it to not include the port? I tried setting port: nil in the Endpoint config, but that didn’t help.

1 Like

I found it. Had to use port: 443

config :my_web, MyWeb.Endpoint,
    url: [host: "mydomain.com", scheme: "https", port: 443],
    http: [port: 5000]

Now MyWeb.Router.Helpers.url(MyWeb.Endpoint) is returning
https://mydomain.com

14 Likes

I ran into this as well—thanks for posting your solution. It seems that the url config port fallback to http config port is not documented.

4 Likes

same here :slight_smile: Thanks for the hining solution :slight_smile: