Skip to content

Commit af11acb

Browse files
wip
1 parent 51554eb commit af11acb

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

client-challenge/server/main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414

1515
"github.com/go-chi/chi/v5"
1616
"github.com/go-chi/chi/v5/middleware"
17+
"github.com/go-chi/cors"
1718
"github.com/go-chi/render"
1819
"github.com/google/uuid"
1920
"github.com/r3labs/sse/v2"
@@ -45,6 +46,13 @@ func main() {
4546
r.Use(middleware.Logger)
4647
r.Use(middleware.Recoverer)
4748
r.Use(middleware.Timeout(30 * time.Second))
49+
r.Use(cors.Handler(cors.Options{
50+
AllowOriginFunc: func(r *http.Request, origin string) bool { return true },
51+
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
52+
AllowedHeaders: []string{"Accept", "Authorization", "Content-Type", "X-CSRF-Token"},
53+
AllowCredentials: true,
54+
MaxAge: 300,
55+
}))
4856

4957
r.Handle("/events", http.HandlerFunc(events.ServeHTTP))
5058

0 commit comments

Comments
 (0)