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

Join the AI Workshop to learn more about AI and how it can be applied to web development. Next cohort February 1st, 2026

The AI-first Web Development BOOTCAMP cohort starts February 24th, 2026. 10 weeks of intensive training and hands-on projects.


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)

Lessons in this unit:

0: Introduction
1: Fix .md in links
2: Moving a simple site to Astro
3: ▶︎ Astro, fix Form error “Content-Type was not one of…”
4: Astro page layout and middleware execution order
5: Astro, set caching headers
6: Astro, set response header
7: Deploying an Astro + PostgreSQL app on Railway
8: Using Astro locals
9: Using Cloudflare Turnstile on a Astro form
10: Using reCAPTCHA on a Astro form
11: Why not write logic in Astro layouts