Retro v0.3.1 Retro.Phoenix.Router.Helpers View Source

Toolkit for extending Phoenix.Router.Helpers.

Link to this section Summary

Functions

Generates the connection/endpoint base URL according to reverse proxy related headers.

Link to this section Functions

Link to this function

base_url(conn)

View Source (since 0.3.0)

Generates the connection/endpoint base URL according to reverse proxy related headers.

Derive protocol from following headers:

  • x-forwarded-proto

Derive host from following headers:

  • x-forwarded-host
  • x-forwarded-server

Examples

iex> base_url(%Plug.Conn{req_headers: [ {"x-forwarded-host", "example.com"}, {"x-forwarded-proto", "https"} ]})
"https://example.com"

iex> base_url(%Plug.Conn{})
nil