mirror of
https://github.com/gabehf/BudgetBuddy.git
synced 2026-03-15 02:06:01 -07:00
cors
This commit is contained in:
parent
7524edbce4
commit
87b444b283
3 changed files with 15 additions and 0 deletions
12
main.go
12
main.go
|
|
@ -6,6 +6,7 @@ import (
|
|||
"net/http"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/go-chi/cors"
|
||||
"github.com/jacobmveber-01839764/BudgetBuddy/db"
|
||||
"github.com/jacobmveber-01839764/BudgetBuddy/routes"
|
||||
"github.com/jacobmveber-01839764/BudgetBuddy/widgets"
|
||||
|
|
@ -26,6 +27,17 @@ func main() {
|
|||
// disconnect to DB on application exit
|
||||
defer db.Client.Disconnect(context.Background())
|
||||
|
||||
r.Use(cors.Handler(cors.Options{
|
||||
// AllowedOrigins: []string{"https://foo.com"}, // Use this to allow specific origin hosts
|
||||
AllowedOrigins: []string{"https://*", "http://*"},
|
||||
// AllowOriginFunc: func(r *http.Request, origin string) bool { return true },
|
||||
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
|
||||
AllowedHeaders: []string{"Accept", "Authorization", "Content-Type", "X-CSRF-Token"},
|
||||
ExposedHeaders: []string{"Link"},
|
||||
AllowCredentials: false,
|
||||
MaxAge: 300, // Maximum value not ignored by any of major browsers
|
||||
}))
|
||||
|
||||
r.Post("/auth/login", routes.Login)
|
||||
r.Post("/auth/login/session", routes.Login)
|
||||
r.Post("/auth/createaccount", routes.CreateAccount)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue