Reference

INVALID_IMAGE_OPTIMIZE_REQUEST

The query string is using an invalid value for q, w, or url parameters. This is a request error.
Table of Contents

The INVALID_IMAGE_OPTIMIZE_REQUEST error occurs when the query string is using an invalid value for q (quality) or w (width), or url returns a non-image response.

400

INVALID_IMAGE_OPTIMIZE_REQUEST

Bad Request

To troubleshoot this error, follow these steps:

  1. Check for typos: Verify that there are no typos in the parameter names or values
  2. Review request format: Ensure that the request URL is correctly formatted and includes the required parameters
    • The q parameter controls the quality of the image and must follow these rules:
      • The q parameter must be an integer
      • The q integer must be greater than or equal to 1
      • The q integer must be less than or equal to 100
      • The q integer must be the same as one specified in qualities, if defined
    • The w parameter defines the width of the image and must follow these rules:
    • The url parameter specifies the image location and must follow these rules:
      • The url parameter must start with /, http://, or https://
      • The url parameter must match one of the configured remotePatterns or localPatterns in your next.config.js
      • The url parameter must have a Content-Type header that starts with image/
      • The url parameter must have a response body less than 300 MB (or less than 100 MB for hobby), otherwise the image won't be optimized

Run next dev locally to reproduce the error and get additional details.

Last updated on January 6, 2025