fix(image): allow any quality 1-100 when images.qualities is unset - #2023
Merged
james-elicx merged 2 commits intoJun 15, 2026
Merged
Conversation
The image optimization endpoint returned 400 for any quality other than
75 (e.g. `<Image quality={90}>`) because vinext defaulted the allowed
quality list to `[75]` whenever `images.qualities` was not configured.
Next.js only enforces a quality allowlist when `images.qualities` is set;
when unset it permits any integer quality from 1-100. This aligns vinext
with that behaviour: `parseImageParams`/`resolveDevImageRedirect` now take
an optional allowlist and only restrict quality when one is provided, and
the build/runtime plumbing emits `null` (not `[75]`) when unset so the
"allow all" semantics survive into the deploy worker.
Repro: GET /_next/image?url=%2Fshop%2Ftablet.png&w=750&q=90 -> 400.
Fixes the app-router-playground image optimization failure.
commit: |
With `images.qualities` unset, any quality 1-100 is now permitted (Next.js parity), so q=70 is a normal quality rather than a rejected one. Pin the blur-quality-exception tests to `qualities: [75]` so they still exercise the dev-only exception, and add a case asserting q=70 is allowed in production when qualities is unset.
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.
Problem
The image optimization endpoint returns 400 Bad Request for any quality other than
75. For example, the app-router-playground product card uses<Image quality={90}>, and the deployed endpoint fails:Only
q=75worked;q=50,q=90,q=100all 400'd regardless of width.Root cause
parseImageParamsdefaulted the allowed-quality list toDEFAULT_IMAGE_QUALITIES = [75]wheneverimages.qualitieswas not configured, and the build/runtime plumbing baked[75]into the deploy worker (__VINEXT_IMAGE_QUALITIES ?? "[75]").Next.js only enforces a quality allowlist when
images.qualitiesis explicitly set. When unset, it permits any integer quality from 1–100 — the allowlist block is skipped entirely:Fix
parseImageParams/resolveDevImageRedirecttake an optionalallowedQualitiesand only enforce the allowlist when one is provided (still range-checks 1–100 and preserves the devBLUR_QUALITYexception).[75]default and the?? DEFAULT_IMAGE_QUALITIES/?? "[75]"fallbacks; the build now emitsnullwhenqualitiesis unset so the "allow all" semantics survive into the deploy worker.parseImageParams.Tests
qualitiesis unset.qualitiesis configured.[75]-only behaviour.Follow-up
A stacked PR will address the remaining
validateParamsparity gaps (recursive/_next/imageguard,localPatterns,remotePatterns,minimumCacheTTL).