| 54 | } |
| 55 | |
| 56 | func RequestURL(r *http.Request) *url.URL { |
| 57 | source := *r.URL |
| 58 | source.Host = cmp.Or(source.Host, r.Header.Get("X-Forwarded-Host"), r.Host) |
| 59 | |
| 60 | if proto := r.Header.Get("X-Forwarded-Proto"); len(proto) > 0 { |
| 61 | source.Scheme = proto |
| 62 | } |
| 63 | |
| 64 | if source.Scheme == "" { |
| 65 | source.Scheme = "https" |
| 66 | if r.TLS == nil { |
| 67 | source.Scheme = "http" |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | return &source |
| 72 | } |
| 73 | |
| 74 | // SendFlowCompletedAsRedirectOrJSON should be used when a login, registration, ... flow has been completed successfully. |
| 75 | // It will redirect the user to the provided URL if the request accepts HTML, or return a JSON response if the request is |