How to Fix Fastify 'Unsupported Media Type: application/x-www-form-urlencoded'

Tadashi Shigeoka ·  Thu, September 23, 2021

I’ll introduce how to fix the Unsupported Media Type: application/x-www-form-urlencoded error in Fastify.

Fastify

Prerequisite Knowledge: Fastify Only Supports JSON

Solving 'Unsupported Media Type: application/x-www-form-urlencoded' with fastify-formbody

Installing fastify-formbody

npm install fastify-formbody --save

fastify.register fastify-formbody

In app.js, just specify fastify-formbody in fastify.register and you’re all set.

fastify.register(require('fastify-formbody'))

That’s all from the Gemba on fixing Unsupported Media Type: application/x-www-form-urlencoded in Fastify.

Reference Information