cors
This commit is contained in:
parent
0d62c6f4db
commit
0a2c2fdee3
2
go.mod
2
go.mod
@ -9,7 +9,7 @@ require (
|
||||
github.com/lib/pq v1.10.9
|
||||
github.com/maragudk/gomponents v0.22.0
|
||||
github.com/maragudk/gomponents-htmx v0.5.1
|
||||
github.com/rs/cors v1.11.0
|
||||
github.com/rs/cors v1.11.1
|
||||
github.com/willoma/bulma-gomponents v0.13.0
|
||||
github.com/willoma/gomplements v0.8.0
|
||||
golang.org/x/crypto v0.34.0
|
||||
|
||||
28
main.go
28
main.go
@ -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", c.Handler(apiMux))
|
||||
err = http.ListenAndServe(":4001", cors.AllowAll().Handler(apiMux))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user