updated deps, new cors rules, code refactor

This commit is contained in:
2023-12-03 11:13:37 +01:00
parent 1636191f0d
commit 0ab9f15184
4 changed files with 85 additions and 18 deletions

View File

@@ -85,6 +85,8 @@ func (s *Service) GetTemplates(ctx context.Context) (*[]internal.CustomTemplate,
return nil, err
}
defer rows.Close()
templates := make([]internal.CustomTemplate, 0)
for rows.Next() {

View File

@@ -73,7 +73,21 @@ func newServer(c serverConfig) *http.Server {
r := chi.NewRouter()
r.Use(cors.AllowAll().Handler)
corsMiddleware := cors.New(cors.Options{
AllowedOrigins: []string{"*"},
AllowedMethods: []string{
http.MethodHead,
http.MethodGet,
http.MethodPost,
http.MethodPut,
http.MethodPatch,
http.MethodDelete,
},
AllowedHeaders: []string{"*"},
AllowCredentials: true,
})
r.Use(corsMiddleware.Handler)
r.Use(middleware.Logger)
app := http.FileServer(http.FS(c.frontend))