Allow CORS origins
This commit is contained in:
@ -12,6 +12,8 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/handlers"
|
||||
|
||||
dashapi "github.com/moustachioed/dash/backend/dashapi"
|
||||
database "github.com/moustachioed/dash/backend/database"
|
||||
mapping "github.com/moustachioed/dash/backend/mapping"
|
||||
@ -29,8 +31,15 @@ func main() {
|
||||
DefaultApiService := service.NewApiService(db, mapper)
|
||||
DefaultApiController := dashapi.NewDefaultApiController(DefaultApiService)
|
||||
|
||||
cors := handlers.CORS(
|
||||
// handlers.AllowedMethods([]string{"GET", "POST", "DELETE"}),
|
||||
handlers.AllowedHeaders([]string{"Accept", "Accept-Language", "Content-Type", "Content-Language", "Origin"}),
|
||||
handlers.AllowedOrigins([]string{"*"}),
|
||||
)
|
||||
|
||||
router := dashapi.NewRouter(DefaultApiController)
|
||||
router.Methods("GET", "POST", "DELETE", "OPTIONS")
|
||||
|
||||
log.Printf("Starting server.")
|
||||
log.Fatal(http.ListenAndServe(":8080", router))
|
||||
log.Fatal(http.ListenAndServe(":8080", cors(router)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user