Error codesRouter

An API route refused a write sent from another site

MARKLESS_ROUTER_CROSS_SITE_WRITE_REFUSEDerrorMarkless raises it while a page runs.

The message

MARKLESS_ROUTER_CROSS_SITE_WRITE_REFUSED: this api/ route refused a write that a browser sent from another site. Writes are accepted from pages on this origin and from callers that are not browsers, such as curl or another server.

Why

A browser sends your cookies with every request to your app, even one that a page on another site starts. So a page elsewhere could send a form to your POST route as if a signed-in visitor sent it. To stop that, every route in api/ answers 403 to a request that changes data (any method except GET, HEAD and OPTIONS) when the browser says it came from another site. The browser says so in the Sec-Fetch-Site header, or in older browsers only through the Origin header.

Fix

Send the write from a page on the same origin as the route: same scheme, host and port, so admin.example.com cannot write to example.com. If another site really needs to write, let its server call the route: a request with neither header passes. If your own pages are refused in an older browser, check whether a proxy in front of the app changes the host or the scheme the server sees. See API routes.

Where Markless raises it

All error codes

Button sounds are from Josh Comeau's Button Sounds library.