Skip to content

Commit 38bbb4f

Browse files
committed
fix: only allow application/json
1 parent 81eed05 commit 38bbb4f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

backend/pkg/api/auth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func getSlidingSessionExpirationMiddleware(scs *scs.SessionManager) func(http.Ha
5858
func contentTypeMiddleware(next http.Handler) http.Handler {
5959
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
6060
// if body is not empty, check if content type is set to json
61-
if (r.Method == http.MethodPost || r.Method == http.MethodPut) && r.ContentLength > 0 && regexp.MustCompile(`^application\/json(;.*)?$`).MatchString(r.Header.Get("Content-Type")) {
61+
if (r.Method == http.MethodPost || r.Method == http.MethodPut) && r.ContentLength > 0 && !regexp.MustCompile(`^application\/json(;.*)?$`).MatchString(r.Header.Get("Content-Type")) {
6262
http.Error(w, "bad request: Content-Type header must be application/json", http.StatusBadRequest)
6363
return
6464
}

0 commit comments

Comments
 (0)