I am not capturing the domain

I am trying to learn to build an app where an anonymous user gets a link thru SMS, with token to do a survey. My controller is not correct. Please help.

defmodule UndiOnlineWeb.SetterController do
use UndiOnlineWeb, :controller

def generate_survey_link(conn, _params) do
# Generate a token for the authenticated user
token = UndiOnlineWeb.Helper.generate_token()
conn = assign(conn, :token, token)

# Construct the survey URL with the token
survey_url = ~p"/survey?token=#{token}"
# Render a view that displays the survey URL

render(conn, :index, survey_url: survey_url)


In my template I am getting /survey?token… Should be http://localhost:4000/survey

And my template

Here's a link to the survey:

Copy Link

You need to generate the full URL, not just the path: Phoenix.VerifiedRoutes — Phoenix v1.7.0-rc.3