Skip to content

Commit a28dc20

Browse files
feat: restrict CORS to specific origins and improve header handling
1 parent 3498e64 commit a28dc20

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

backend/main.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,22 @@ func main() {
6161

6262
// CORS
6363
c := cors.New(cors.Options{
64-
AllowedOrigins: []string{"*"},
64+
AllowedOrigins: []string{
65+
"http://localhost:3000",
66+
"https://four-in-a-row.myselfankit.tech",
67+
},
6568
AllowedMethods: []string{
6669
http.MethodGet,
6770
http.MethodPost,
6871
http.MethodPut,
6972
http.MethodPatch,
7073
http.MethodDelete,
71-
http.MethodOptions,
72-
http.MethodHead,
7374
},
74-
AllowedHeaders: []string{"*"},
75+
AllowedHeaders: []string{
76+
"Content-Type",
77+
"Authorization",
78+
},
79+
AllowCredentials: true,
7580
})
7681

7782
handler := c.Handler(mux)

0 commit comments

Comments
 (0)