|
|
|
|
@ -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)
|
|
|
|
|
|