Skip to content

Instantly share code, notes, and snippets.

@aaronmu
Created February 13, 2020 05:49
Show Gist options
  • Select an option

  • Save aaronmu/22bd671b9dd9e24502af4baca62b7827 to your computer and use it in GitHub Desktop.

Select an option

Save aaronmu/22bd671b9dd9e24502af4baca62b7827 to your computer and use it in GitHub Desktop.

Revisions

  1. aaronmu created this gist Feb 13, 2020.
    10 changes: 10 additions & 0 deletions SchemeMiddleware.fs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    type ChangesRequestSchemeBasedOnXForwardedProto(next : RequestDelegate) =
    member this.Invoke(context : HttpContext) =
    let xForwardedProto = context.Request.Headers.["X-Forwarded-Proto"]

    if xForwardedProto = (StringValues "https") then
    context.Request.Scheme <- "https"
    else
    ()

    next.Invoke(context)