cors
All checks were successful
build and deploy portfolio / build (push) Successful in 37s
build and deploy portfolio / publish-portfolio (push) Successful in 3s
build and deploy portfolio / publish-docs (push) Successful in 5s

This commit is contained in:
darius 2025-02-25 22:48:44 +01:00
parent 0a2c2fdee3
commit ee1be74eba

28
main.go
View File

@ -31,24 +31,24 @@ func main() {
}
}()
//c := cors.New(cors.Options{
// AllowedOrigins: []string{"http://localhost:4000", "https://*.dariusklein.nl", "https://*.portfolio.dariusklein.nl", "https://dariusklein.nl"},
// AllowedMethods: []string{
// http.MethodHead,
// http.MethodGet,
// http.MethodPost,
// http.MethodPut,
// http.MethodPatch,
// http.MethodDelete,
// },
// AllowedHeaders: []string{"*"},
// AllowCredentials: true,
//})
c := cors.New(cors.Options{
AllowedOrigins: []string{"http://localhost:4000", "https://*.dariusklein.nl", "https://*.portfolio.dariusklein.nl", "https://dariusklein.nl"},
AllowedMethods: []string{
http.MethodHead,
http.MethodGet,
http.MethodPost,
http.MethodPut,
http.MethodPatch,
http.MethodDelete,
},
AllowedHeaders: []string{"*"},
AllowCredentials: true,
})
//init api routes
apiMux := api.Routes()
//run api server
err = http.ListenAndServe(":4001", cors.AllowAll().Handler(apiMux))
err = http.ListenAndServe(":4001", c.Handler(apiMux))
if err != nil {
log.Fatal(err)
}