feat: Handle X-Forwarded-Proto header
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:
Julien Riou 2025-10-02 07:21:15 +02:00
commit acfad88cb8
Signed by: jriou
GPG key ID: 9A099EDA51316854
2 changed files with 5 additions and 2 deletions

View file

@ -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

View file

@ -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://"
}