forked from jriou/coller
feat: Handle X-Forwarded-Proto header
Fixes #39. Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
de24146991
commit
acfad88cb8
2 changed files with 5 additions and 2 deletions
|
@ -161,7 +161,7 @@ func (d *Database) Create(content []byte, password []byte, encryptionKey string,
|
|||
note.Encrypted = true
|
||||
}
|
||||
|
||||
if password != nil {
|
||||
if len(password) > 0 {
|
||||
hash, err := bcrypt.GenerateFromPassword(password, bcrypt.DefaultCost)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -177,8 +177,11 @@ func (h *CreateNoteWithFormHandler) ServeHTTP(w http.ResponseWriter, r *http.Req
|
|||
}
|
||||
|
||||
logger.Debug("building note url")
|
||||
|
||||
var scheme = "http://"
|
||||
if r.TLS != nil {
|
||||
if proto := r.Header.Get("X-Forwarded-Proto"); proto != "" {
|
||||
scheme = proto + "://"
|
||||
} else if r.TLS != nil {
|
||||
scheme = "https://"
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue