在运行时更改phoenix端点url主机



有人知道在每次请求时动态更改Phoenix应用程序端点的:host的方法吗?

特别是为了在一个phoenix应用程序上支持多个域,我想根据连接对象中的主机更改端点中的主机。

我正在尝试

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

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

但是我不太正确。

这不是您在重定向中为:to关键字分配的值吗?

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

master_proxy包提供了一些有用的工具来支持多个站点。

最新更新