Next.js: Specified "headers" cannot be used with "output: export" / Image Optimization using the default loader is not compatible with `{ output: 'export' }`
Static export (output: 'export') can't use server features like rewrites/headers/redirects, default image optimisation, middleware or dynamic APIs.
Specified "headers" cannot be used with "output: export"Image Optimization using the default loader is not compatible with `{ output: 'export' }`Specified "redirects" cannot be used with "output: export"Specified "rewrites" cannot be used with "output: export"Middleware cannot be used with "output: export" Meaning
Use images: { unoptimized: true } (or a custom loader), configure headers/redirects at the host (Netlify _headers, Nginx), remove middleware/route handlers that need a server, and avoid cookies()/headers(). Or deploy as a normal Node/Vercel app instead of export.
Common causes
- next/image default loader with export
headers/redirects/rewritesin next.config- Middleware or API routes present
- Server Actions or dynamic APIs
- ISR/revalidate expectations
⚡ Quick fix
images: { unoptimized: true }- Move headers/redirects to the hosting layer
- Remove server-only features or drop
output: "export"
Detailed fix by platform
Next.js
module.exports = { output: "export", images: { unoptimized: true } };
How to diagnose
- Feature — Which unsupported?
- Hosting — Static only?
- Alternative — Server deploy?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- Conflicting app and page file was found Next.js: ⨯ Conflicting app and page file was found, please remove the conflicting files to continue: "pages/index.tsx" - "app/page.tsx"
- Invalid next.config.js options detected Next.js: Invalid next.config.js options detected: Unrecognized key(s) in object: 'xyz'
- next build: fetch failed ECONNREFUSED (build-time API) Next.js: Error occurred prerendering page "/blog" TypeError: fetch failed { cause: Error: connect ECONNREFUSED 127.0.0.1:3000 }
Most viewed in Next.js
- NEXT_REDIRECT Next.js: Error: NEXT_REDIRECT (redirect() inside try/catch)
- server-only Next.js: You're importing a component that needs "server-only". That only works in a Server Component
- cookies() should be awaited Next.js 15: Route "/x" used `cookies().get('token')`. `cookies()` should be awaited before using its value
Other ways to find it
Where this error sits
Origin: On your device. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026