Changing phoenix endpoint url node at runtime

Does anyone know a way to change the :hostendpoint of a Phoenix application dynamically with every request?

In particular, in order to support multiple domains in a single phoenix application, I want to change the host at the endpoint based on the host in the connection object.

Try something in the lines

conn = Map.get_and_update(conn.private.phoenix_endpoint[:url], :host, fn (_) -> "ll.com" end)

or

Keyword.put(conn.private.phoenix_endpoint.config(:url), :host, conn.host)

But I'm not quite right.

+4
source share
1 answer

Wouldn't that just be a keyword assignment :toin a redirect?

def index(conn, params) do
  redirect conn, to: params[:location] # or whatever
end 
0
source

Source: https://habr.com/ru/post/1617693/


All Articles