From a1c9918d437f2544ad23d5c1e4b992ae49503c9b Mon Sep 17 00:00:00 2001 From: Filiprogrammer <44641787+Filiprogrammer@users.noreply.github.com> Date: Fri, 17 May 2024 19:26:53 +0200 Subject: [PATCH] Add CORS headers to HTTP responses Improve compatibility with other services, by allowing cross origin requests. --- invoice_manager.go | 1 + main.go | 1 + 2 files changed, 2 insertions(+) diff --git a/invoice_manager.go b/invoice_manager.go index 434c960..086e959 100644 --- a/invoice_manager.go +++ b/invoice_manager.go @@ -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 { diff --git a/main.go b/main.go index 22c9a6f..fb17cc3 100644 --- a/main.go +++ b/main.go @@ -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) }