Skip to content

Nuxt 406 response is missing Vary: Accept and Content-Type (spec section 4) #80

Description

@abhay-codes07

Summary

When a request explicitly excludes both text/html and text/markdown (e.g. Accept: application/json), the Nuxt adapter returns a 406 with no headers at all:

return new Response('Not Acceptable', { status: 406 });

No Vary: Accept, no Content-Type, no supported-types body.

Spec

content-negotiation.md section 4:

The 406 response:

  • MUST set Vary: Accept
  • SHOULD include a body listing supported types

The missing Vary: Accept is a MUST violation (a shared cache can key the 406 incorrectly), and the missing Content-Type means the plain-text body can be mis-sniffed.

Where

Both the generated collection middleware and the runtime middleware:

  • packages/nuxt/src/module.ts (the getMiddlewareCode template, ~line 284)
  • packages/nuxt/src/runtime/server/endpoints/middleware.ts (~line 38)

Every other adapter already sets these headers on its 406 (e.g. packages/cloudflare/src/worker.ts).

Proposed fix

Return the 406 with Content-Type: text/plain; charset=utf-8, Vary: Accept, and a supported-types body, matching the other adapters. PR incoming.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions