summaryrefslogtreecommitdiff
path: root/app/app.go
diff options
context:
space:
mode:
authorJames Mills <prologic@shortcircuit.net.au>2020-03-25 07:23:28 +1000
committerJames Mills <prologic@shortcircuit.net.au>2020-03-25 07:23:28 +1000
commitb6f36d2738fa9b929a58b5c750e64afe351965ec (patch)
tree6a70bef8be2e6023106586da9015da52a61c6d88 /app/app.go
parentdb6322d9870d087a0d4d7791b085b833659d437b (diff)
Add custom CORS config
Diffstat (limited to 'app/app.go')
-rw-r--r--app/app.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/app/app.go b/app/app.go
index 0ce959c..aa6b129 100644
--- a/app/app.go
+++ b/app/app.go
@@ -91,6 +91,15 @@ func NewApp(cfg *Config) (*App, error) {
http.FileServer(rice.MustFindBox("../static").HTTPBox()),
)
r.PathPrefix("/static/").Handler(fsHandler).Methods("GET")
+
+ cors := handlers.CORS(
+ handlers.AllowedHeaders([]string{"Content-Type"}),
+ handlers.AllowedOrigins([]string{"*"}),
+ handlers.AllowCredentials(),
+ )
+
+ r.Use(cors)
+
a.Router = r
return a, nil
}
@@ -114,7 +123,7 @@ func (a *App) Run() error {
}
buildFeed(a)
go startWatcher(a)
- return http.Serve(a.Listener, handlers.CORS()(a.Router))
+ return http.Serve(a.Listener, a.Router)
}
func (a *App) render(name string, w http.ResponseWriter, ctx interface{}) {