updated deps, new cors rules, code refactor
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user