cors
All checks were successful
Build and Publish / BuildAndDeployAmd64 (push) Successful in 28s
Build and Publish / BuildAndDeploy (push) Successful in 2m15s

This commit is contained in:
matst80
2024-11-14 23:17:29 +01:00
parent 12d695bec3
commit b79f7904b1

View File

@@ -60,6 +60,7 @@ func ErrorHandler(fn func(w http.ResponseWriter, r *http.Request) error) func(w
func (s *PoolServer) WriteResult(w http.ResponseWriter, result *FrameWithPayload) error { func (s *PoolServer) WriteResult(w http.ResponseWriter, result *FrameWithPayload) error {
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")
w.Header().Set("X-Pod-Name", s.pod_name) w.Header().Set("X-Pod-Name", s.pod_name)
w.Header().Set("Access-Control-Allow-Origin", "https://tornberg.me")
if result.StatusCode != 200 { if result.StatusCode != 200 {
log.Printf("Call error: %d\n", result.StatusCode) log.Printf("Call error: %d\n", result.StatusCode)
if result.StatusCode >= 200 && result.StatusCode < 600 { if result.StatusCode >= 200 && result.StatusCode < 600 {
@@ -239,6 +240,10 @@ func (s *PoolServer) HandleCheckout(w http.ResponseWriter, r *http.Request) erro
buf := new(bytes.Buffer) buf := new(bytes.Buffer)
buf.ReadFrom(res.Body) buf.ReadFrom(res.Body)
w.Header().Set("Content-Type", "application/json")
w.Header().Set("X-Pod-Name", s.pod_name)
w.Header().Set("Access-Control-Allow-Origin", "https://tornberg.me")
w.WriteHeader(res.StatusCode)
w.Write(buf.Bytes()) w.Write(buf.Bytes())
return nil return nil