Skip to content

Commit

Permalink
Add CORS header to let the UI hit the API
Browse files Browse the repository at this point in the history
  • Loading branch information
fsufitch committed Feb 12, 2020
1 parent 9ce255c commit 2584dcb
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions web/security.go
Expand Up @@ -22,6 +22,7 @@ type wrappedHandler struct {

func (h wrappedHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
auth := r.Header.Get("Authorization")
w.Header().Set("Access-Control-Allow-Origin", "*") // TODO: make this smarter?
if !strings.HasPrefix(auth, "Bearer ") {
plainTextResponse(w, http.StatusUnauthorized, []byte("Missing `Authorization: Bearer ...` header"))
h.log.HTTP(http.StatusUnauthorized, r)
Expand Down

0 comments on commit 2584dcb

Please sign in to comment.