Skip to content

Unexpected redirect when rewritten URLs don't match trailingSlash setting #25673

@vbudovski

Description

@vbudovski

What version of Next.js are you using?

10.2.3

What version of Node.js are you using?

14.15.5

What browser are you using?

Chrome

What operating system are you using?

macOS

How are you deploying your application?

N/A

Describe the Bug

  • A rewritten URL containing a trailing slash will be redirected with a 308 if the trailingSlash setting is set to false.
  • A rewritten URL with no trailing slash will be redirected with a 308 if the trailingSlash setting is set to true.
  • A rewritten URL with a trailing slash will not be redirected if the trailingSlash setting is set to true.
  • A rewritten URL with no trailing slash will not be redirected if the trailingSlash setting is set to false.

Possibly related to #20984

Expected Behavior

Rewrites occur without a redirect in all of the above scenarios.

To Reproduce

Please see attached example rewrite-test.tar.gz

  1. Note the current trailingSlash setting in next.config.js.
  2. Run yarn dev.
  3. Load http://localhost:3000 and click on each of the buttons, observing the presence/absence of redirects.
  4. Shut down server and toggle the trailingSlash setting.
  5. Repeat steps 1-3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue was opened via the bug report template.please add a complete reproductionPlease add a complete reproduction.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions