Skip to content

Commit

Permalink
Detect scheme correct when behind a reverse proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
v1k45 committed Jun 2, 2024
1 parent 87aebd1 commit 9767b4b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions web/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ func (h *Handler) Paste(w http.ResponseWriter, r *http.Request) {
}

var scheme string
if r.TLS == nil {
scheme = "http"
if r.Header.Get("X-Forwarded-Proto") != "" {
scheme = r.Header.Get("X-Forwarded-Proto")
} else {
scheme = "https"
scheme = "http"
}

url := fmt.Sprintf("%s://%s/p/%s/%s", scheme, r.Host, paste.ID, paste.Key)

component := views.PasteSuccess(url)
Expand Down

0 comments on commit 9767b4b

Please sign in to comment.