Last active
March 18, 2021 18:58
-
-
Save mveytsman/f3b4a24490853b3fabfae8a633ac48ea to your computer and use it in GitHub Desktop.
Gigalixir canonical host
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule GigalixirCanonicalHost do | |
defdelegate init(opts), to: PlugCanonicalHost | |
def call(conn, opts) do | |
# There's a bug in gigagilir where requests to foo.gigaglixirapp.com | |
# get `x-forwarded-proto: https` but `x-forwarded-port: 80` which messes up canonical host | |
conn = | |
if Plug.Conn.get_req_header(conn, "x-forwarded-proto") == "https" && | |
Plug.Conn.get_req_header(conn, "x-forwarded-port") == "80" do | |
conn | |
|> Plug.Conn.set_req_header("x-forwarded-port", "443") | |
else | |
conn | |
end | |
opts = | |
PlugCanonicalHost.call(conn, opts) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment