Skip to content

Commit

Permalink
fix: pass client headers via naarad-api to naarad
Browse files Browse the repository at this point in the history
  • Loading branch information
proffapt committed Jun 30, 2024
1 parent a97472e commit a602c31
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions backend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,11 @@ func register(res http.ResponseWriter, req *http.Request) {

// Create user using ntfy api
signupData := fmt.Sprintf(`{"username": "%s", "password": "%s"}`, username, password)
req, _ = http.NewRequest("POST", ntfyServerAddr+"/v1/account", strings.NewReader(signupData))
resp, err = client.Do(req)
reqNtfy, _ := http.NewRequest("POST", ntfyServerAddr+"/v1/account", strings.NewReader(signupData))
for name, values := range req.Header {
reqNtfy.Header[name] = values
}
resp, err = client.Do(reqNtfy)
if err != nil {
fmt.Println("NTFY User Registration API Error: ", err.Error())
http.Error(res, "Failed to request user registration for Naarad", http.StatusInternalServerError)
Expand Down
2 changes: 1 addition & 1 deletion metaploy/naarad.metaploy.conf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ server {
location = /v1/account {
valid_referers https://naarad-signup.metakgp.org;
if ($invalid_referer) {
return 307 https://naarad-signup.metakgp.org;
return 401;
}
}

Expand Down
2 changes: 1 addition & 1 deletion server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ listen-http: ":8000"
# ntfy user and group by running: chown ntfy.ntfy <filename>.
#
cache-file: /var/cache/ntfy/cache.db
cache-duration: "24h"
cache-duration: "3d"
cache-batch-size: 25
cache-batch-timeout: "1s"
cache-startup-queries: |
Expand Down

0 comments on commit a602c31

Please sign in to comment.