feat: Handle X-Forwarded-Proto header
All checks were successful
/ pre-commit (push) Successful in 1m40s
All checks were successful
/ pre-commit (push) Successful in 1m40s
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
|
note.Encrypted = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if password != nil {
|
if len(password) > 0 {
|
||||||
hash, err := bcrypt.GenerateFromPassword(password, bcrypt.DefaultCost)
|
hash, err := bcrypt.GenerateFromPassword(password, bcrypt.DefaultCost)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -177,8 +177,11 @@ func (h *CreateNoteWithFormHandler) ServeHTTP(w http.ResponseWriter, r *http.Req
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Debug("building note url")
|
logger.Debug("building note url")
|
||||||
|
|
||||||
var scheme = "http://"
|
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://"
|
scheme = "https://"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue