fix(nuxt): set Vary and Content-Type on the 406 response#81
Open
abhay-codes07 wants to merge 1 commit into
Open
fix(nuxt): set Vary and Content-Type on the 406 response#81abhay-codes07 wants to merge 1 commit into
abhay-codes07 wants to merge 1 commit into
Conversation
The Nuxt adapter returned a bare 'Not Acceptable' 406 with no headers. Per content-negotiation.md section 4 a 406 MUST set Vary: Accept, and it should carry a Content-Type and a supported-types body. Match the other adapters (text/plain, Vary: Accept, supported-types body) in both the generated collection middleware and the runtime middleware.
|
@abhay-codes07 is attempting to deploy a commit to the Dodo Payments Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Pull request overview
This PR brings the Nuxt adapter’s 406 (“Not Acceptable”) response into compliance with the content negotiation spec by ensuring it includes the required response headers and a supported-types body, matching the behavior of other adapters.
Changes:
- Update Nuxt runtime middleware and the generated middleware template to return a typed
text/plain406 withVary: Acceptand a supported-types body. - Extend the Nuxt middleware test to assert
VaryincludesAcceptandContent-Typeistext/plain. - Add a changeset to release the fix as a patch for
@dualmark/nuxt.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/nuxt/src/runtime/server/endpoints/middleware.ts | Adds Vary: Accept, Content-Type: text/plain; charset=utf-8, and a supported-types body to the runtime 406 response. |
| packages/nuxt/src/module.ts | Updates the getMiddlewareCode template so generated collection middleware returns the same spec-compliant 406 response. |
| packages/nuxt/test/middleware.test.ts | Adds assertions verifying Vary and Content-Type are present on 406 responses. |
| .changeset/nuxt-406-headers.md | Declares a patch release for @dualmark/nuxt and documents the spec-compliance fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| expect(res).toBeInstanceOf(Response); | ||
| expect(res.status).toBe(406); | ||
| // Spec section 4: a 406 MUST set Vary: Accept and should be typed text/plain. | ||
| expect((res.headers.get('vary') ?? '').toLowerCase()).toContain('accept'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Nuxt adapter returned a bare
Not Acceptable406 with no headers, so it was missing the spec-requiredVary: Accept(and had noContent-Typeor supported-types body). This matches it to the other adapters.Closes #80.
Changes
packages/nuxt/src/runtime/server/endpoints/middleware.tsand thegetMiddlewareCodetemplate inpackages/nuxt/src/module.ts: the 406 now returnsContent-Type: text/plain; charset=utf-8,Vary: Accept, and a body listing the supported types.VarycontainsAcceptand theContent-Typeistext/plain.Type
AEO_SPEC_VERSION)Verification
bun run buildpassesbun run testpasses (nuxt: 49 tests)bun run typecheckpassesdualmark verify(no examples touched)/spec/: ran sync-spec (no spec files touched)Changeset
@dualmark/nuxt)cc @thepushkaraj @aagarwal1012.