From fd85a05f4206c7a14272e93b81c427a708ef8ae3 Mon Sep 17 00:00:00 2001 From: Mark Bates Date: Thu, 18 Jan 2018 11:17:11 -0500 Subject: [PATCH] setup cors automatically for api apps --- generators/newapp/templates/actions/app.go.tmpl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/generators/newapp/templates/actions/app.go.tmpl b/generators/newapp/templates/actions/app.go.tmpl index a3eb86c73..5166d1356 100644 --- a/generators/newapp/templates/actions/app.go.tmpl +++ b/generators/newapp/templates/actions/app.go.tmpl @@ -18,6 +18,7 @@ import ( {{ end -}} {{ if .opts.AsAPI -}} + "github.com/rs/cors" "github.com/gobuffalo/x/sessions" {{ end -}} ) @@ -39,6 +40,9 @@ func App() *buffalo.App { Env: ENV, {{ if .opts.AsAPI -}} SessionStore: sessions.Null{}, + PreWares: []buffalo.PreWare{ + cors.Default().Handler, + }, {{ end -}} SessionName: "_{{.opts.Name.File}}_session", })