Skip to content

Commit

Permalink
Add CORS headers to HTTP responses
Browse files Browse the repository at this point in the history
Improve compatibility with other services, by allowing cross origin
requests.
  • Loading branch information
Filiprogrammer committed May 17, 2024
1 parent 131a521 commit a1c9918
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions invoice_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func (m *InvoiceManager) handleInvoiceCreation(config ServerConfig) http.Handler
return func(w http.ResponseWriter, r *http.Request) {
log.Infof("Handling invoice creation: %v\n", *r)
w.Header().Set("Content-Type", "application/json")
w.Header().Set("Access-Control-Allow-Origin", "*")

keys, hasAmount := r.URL.Query()["amount"]
if !hasAmount || len(keys[0]) < 1 {
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ func handleLNUrlp(config ServerConfig, metadata string) http.HandlerFunc {
Callback: config.InvoiceCallback,
}
w.Header().Set("Content-Type", "application/json")
w.Header().Set("Access-Control-Allow-Origin", "*")
w.WriteHeader(http.StatusCreated)
json.NewEncoder(w).Encode(resp)
}
Expand Down

0 comments on commit a1c9918

Please sign in to comment.