Skip to content

Commit

Permalink
fix cors error
Browse files Browse the repository at this point in the history
  • Loading branch information
pomdtr committed Dec 10, 2023
1 parent e7c157d commit bade057
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,17 @@ func NewHandler() (http.Handler, error) {
})

r.Use(cors.Handler(cors.Options{
AllowedOrigins: []string{"https://tweety.sh", "https://wwww.tweety.sh", "chrome-extension://*"},
AllowOriginFunc: func(r *http.Request, origin string) bool {
if origin == "https://www.tweety.sh" || origin == "https://tweety.sh" {
return true
}

if strings.HasPrefix(origin, "chrome-extension://") {
return true
}

return false
},
}))

r.Get("/ping", func(w http.ResponseWriter, r *http.Request) {
Expand Down

0 comments on commit bade057

Please sign in to comment.