Merge pull request #273 from srcenchen/api_cors

[opt] HTTP-API: 支持跨域
pull/274/head
yoko 2 years ago committed by GitHub
commit ef3e637862
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -253,6 +253,7 @@ func (h *HttpApiServer) notFoundHandler(w http.ResponseWriter, req *http.Request
func feedback(v interface{}, w http.ResponseWriter) {
resp, _ := json.Marshal(v)
w.Header().Add("Server", base.LalHttpApiServer)
w.Header().Set("Access-Control-Allow-Origin", "*") // 跨域
w.Header().Set("Content-Type", "application/json")
_, _ = w.Write(resp)
}

Loading…
Cancel
Save