From 6faa676c136f27dc07077ed74659f3559bb5bd69 Mon Sep 17 00:00:00 2001 From: Jianhui Zhao Date: Wed, 21 Mar 2018 21:05:31 +0800 Subject: [PATCH] Support sccess allow origin Signed-off-by: Jianhui Zhao --- main.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/main.go b/main.go index 5c8585e..c78b22e 100644 --- a/main.go +++ b/main.go @@ -88,11 +88,19 @@ func main() { } } + w.Header().Set("Access-Control-Allow-Origin", "*") + w.Header().Add("Access-Control-Allow-Headers", "Content-Type") + w.Header().Set("content-type", "application/json") + js, _ := json.Marshal(devs) w.Write(js) }) http.HandleFunc("/cmd", func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Access-Control-Allow-Origin", "*") + w.Header().Add("Access-Control-Allow-Headers", "Content-Type") + w.Header().Set("content-type", "application/json") + serveCmd(br, w, r) })