Secure headers and CSRF — Middleware · Hono

Tell browsers how to treat the API's responses with secureHeaders(), tune two of its headers and add a content security policy, then stop cross-site forms from posting with csrf().

What you will learn

Read the theory for Secure headers and CSRF

All Middleware lessons

All Hono courses

loading types…

What you'll learn

  • Add the browser security headers Hono sets by default and know what each one prevents
  • Override one header, turn one off, and write a Content-Security-Policy as an object
  • Refuse cross-site form submissions with csrf(), and understand why a JSON request is not its concern