Skip to content

Astro, fix Form error “Content-Type was not one of…”

Working on a form with Astro, I got this error when submitting it:

Content-Type was not one of "multipart/form-data" or "application/x-www-form-urlencoded".

Turns out, the site was not server-side rendered, and/or the page was not hybrid.

I added output: 'server' in the Astro config in astro.config.mjs:

// @ts-check
import { defineConfig } from 'astro/config'

// https://astro.build/config
export default defineConfig({
  **output: 'server'**
})

I could have also added

export const prerender = false

at the top of the file that included the form (and handled form submission)


I wrote 21 books to help you become a better developer:

  • HTML Handbook
  • Next.js Pages Router Handbook
  • Alpine.js Handbook
  • HTMX Handbook
  • TypeScript Handbook
  • React Handbook
  • SQL Handbook
  • Git Cheat Sheet
  • Laravel Handbook
  • Express Handbook
  • Swift Handbook
  • Go Handbook
  • PHP Handbook
  • Python Handbook
  • Linux Commands Handbook
  • C Handbook
  • JavaScript Handbook
  • Svelte Handbook
  • CSS Handbook
  • Node.js Handbook
  • Vue Handbook
...download them all now!

Related posts that talk about astro: