Phx.gen.auth url to https

I’m using phx.gen.auth for user registration and when user creates an account, url to verify account gets created and sent to the user email. I’ve put my app on a server behind a Caddy server which gives me SSL and that all works fine. The problem I have is that account verification url that is sent to the user starts with HTTP instead of HTTPS like I’m not using SSL at all. Is there a way to fix that?

If you’re building the url with MyAppWeb.Endpoint.url/0, then you just need to configure the endpoint to use the https scheme:

config :my_app, MyAppWeb.Endpoint,
  ...
  url: [scheme: "https"],
  ...
4 Likes

It worked but now it’s sending port number:

https://www.domainname.com:80/verify

Is there a way to remove it?

Can you post your config? I currently have deployed a simple config like

config :my_app, MyAppWeb.Endpoint,
  server: true,
  url: [scheme: "https", host: System.get_env("APP_NAME") <> ".gigalixirapp.com", port: 443]

and Endpoint.url/0 does not include the port number.

5 Likes

I was missing port 443, now it works like a charm. Thanks a lot! :slight_smile:

1 Like