Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #868 from gobuffalo/api-cors
Browse files Browse the repository at this point in the history
setup cors automatically for api apps
  • Loading branch information
markbates authored Jan 18, 2018
2 parents 5ce0e31 + bf66292 commit 767a1b1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions generators/newapp/templates/actions/app.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
{{ end -}}

{{ if .opts.AsAPI -}}
"github.com/rs/cors"
"github.com/gobuffalo/x/sessions"
{{ end -}}
)
Expand All @@ -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",
})
Expand Down

0 comments on commit 767a1b1

Please sign in to comment.