playground: allow CORS requests to /share
Update golang/go#21691
Change-Id: I943e2fa260fe5e73407aeabec4d86448817626f9
Reviewed-on: https://go-review.googlesource.com/60690
Reviewed-by: Chris Broadfoot <cbro@golang.org>
diff --git a/app/goplay/share.go b/app/goplay/share.go
index 801751c..f02752d 100644
--- a/app/goplay/share.go
+++ b/app/goplay/share.go
@@ -39,6 +39,11 @@
}
func share(w http.ResponseWriter, r *http.Request) {
+ w.Header().Set("Access-Control-Allow-Origin", "*")
+ if r.Method == "OPTIONS" {
+ // This is likely a pre-flight CORS request.
+ return
+ }
if r.Method != "POST" {
status := http.StatusMethodNotAllowed
http.Error(w, http.StatusText(status), status)