Refuse API writes that are not application/json (closes #271)
check / check (push) Waiting to run

A page on another origin of the same site could send a text/plain or
form POST with the user's cookie, since a browser sends such a request
without a preflight. RequireJSON on the /api/v1 router answers 415 to a
POST, PUT or DELETE whose Content-Type is not application/json, or that
has none, before the handler runs.

The web client and neoirc-cli already send the header on every request.

Model: opus-5-5
This commit is contained in:
sneak committed 2026-11-11 01:33:10 +00:00
1 parent ba79d6de02
commit 2be34bcedf
5 files changed
+255 -3

No files matched your search

+2
View File
@@ -68,6 +68,8 @@ func (srv *Server) SetupRoutes() {
}
func (srv *Server) setupAPIv1(router chi.Router) {
router.Use(srv.mw.RequireJSON())
router.With(srv.mw.CORS()).Get(
"/server",
srv.handlers.HandleServerInfo(),