cors
This commit is contained in:
parent
0a2c2fdee3
commit
ee1be74eba
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", cors.AllowAll().Handler(apiMux))
|
||||
err = http.ListenAndServe(":4001", c.Handler(apiMux))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user