Skip to content

Commit

Permalink
Add CORS support again
Browse files Browse the repository at this point in the history
  • Loading branch information
felixge committed May 8, 2013
1 parent 9380bdf commit fdecaff
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/cmd/tusd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,20 @@ func main() {
panic(err)
}

http.Handle(basePath, tusHandler)
http.HandleFunc(basePath, func(w http.ResponseWriter, r *http.Request) {
// Allow CORS for almost everything. This needs to be revisted / limited to
// routes and methods that need it.
w.Header().Add("Access-Control-Allow-Origin", "*")
w.Header().Add("Access-Control-Allow-Methods", "HEAD,GET,PUT,POST,DELETE")
w.Header().Add("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Content-Range, Content-Disposition")
w.Header().Add("Access-Control-Expose-Headers", "Location, Range, Content-Disposition")

if r.Method == "OPTIONS" {
return
}

tusHandler.ServeHTTP(w, r)
})

go handleUploads(tusHandler)

Expand Down

0 comments on commit fdecaff

Please sign in to comment.