Skip to content

trailingSlash: true redirects /_next/image? to /_next/image/? for each image request #21337

@SevdalinZhelyazkov

Description

@SevdalinZhelyazkov

What version of Next.js are you using?

10.0.2

What version of Node.js are you using?

12.4.1

What browser are you using?

Chrome

What operating system are you using?

Windows

How are you deploying your application?

Other platform

Describe the Bug

When trailingSlash is set to 'true' the /_next/image directory used for serving optimized images is also affected.

Instead of requesting the resource on:
/_next/image?url=/uploads/...

the user is redirected with 308 to
/_next/image/?url=/uploads/...

This creates a huge amount of unnecessary redirects for a page full of images. I couldn't find any additional config options for the trailingSlash option whatsoever.

Expected Behavior

The optimized images path to not be redirected to a path with a trailing slash.

To Reproduce

  1. Create a NextJS application.
  2. Add a couple of next/image images.
  3. Set trailingSlash to true.
  4. Check the network tab and verify that the requests for the images have been redirected with status code 308.
  5. Disable trailingSlash and verify that there are no redirects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Image (next/image)Related to Next.js Image Optimization.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy