Skip to content

Commit

Permalink
Merge pull request #13 from shirou/add_header_to_options
Browse files Browse the repository at this point in the history
add CORS headers to OPTIONS method.
  • Loading branch information
danielgtaylor committed Jan 30, 2019
2 parents 18e97c3 + 2a75d70 commit 842d838
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions apisprout.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,9 @@ func server(cmd *cobra.Command, args []string) {
if !viper.GetBool("disable-cors") {
// Handle pre-flight OPTIONS request
if (*req).Method == "OPTIONS" {
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")
w.Header().Set("Access-Control-Allow-Headers", "Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization")
return
}
}
Expand Down

0 comments on commit 842d838

Please sign in to comment.