Skip to content

Commit

Permalink
more cors
Browse files Browse the repository at this point in the history
  • Loading branch information
tawalaya committed Apr 2, 2019
1 parent 6317403 commit b0f7b10
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ func (v *VDCServer) Clean() {
func (v *VDCServer) Router() *mux.Router {
r := mux.NewRouter()

r.Methods("GET").Path("/ask").Handler(http.HandlerFunc(v.ask))
r.Methods("OPTIONS").Path("/ask").Handler(http.HandlerFunc(v.ask))
r.Methods("GET", "OPTIONS").Path("/ask").Handler(http.HandlerFunc(v.ask))
r.NotFoundHandler = http.HandlerFunc(v.notFound)
return r
}
Expand Down Expand Up @@ -214,9 +213,13 @@ func (v *VDCServer) notFound(w http.ResponseWriter, r *http.Request) {

func (v *VDCServer) ask(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Access-Control-Allow-Methods", "GET, OPTIONS, HEAD")
//w.Header().Set("Access-Control-Allow-Methods", "GET, OPTIONS, HEAD")
w.Header().Set("Access-Control-Allow-Headers", "*")

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

v.Log(fmt.Sprintf("[%s] %s", r.Method, r.RequestURI))
v.Trace(r, "vdc-request")

Expand Down

0 comments on commit b0f7b10

Please sign in to comment.