payloadcms / payloadcms/payload

[Next Combined] Unwanted internal redirection with HOC - SEO Impact

Open
#13,127 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stale status: needs-triage
Dominant language
TypeScript
Stars
44.8k
Forks
4.2k
Avg merge
2d 21h
Merged PRs (30d)
53

Description

Describe the Bug

We've encountered increasing SEO issues lately on some of our apps with Payload + Next combined.

After further investigation, we discovered that the withPayload HOC wrapping next config was triggering post rendering redirects on same url.

This makes certain crawlers like SEMRush treat status 200 pages like 307 redirects

Link to the code that reproduces this issue

https://github.com/Raigato/next-payload-redirection-test

Reproduction Steps

On provided repo:

  1. Run check-redirects": "tsx scripts/checkRedirects.ts, you'll see the page being redirected
yarn check-redirects
[ 'http://localhost:3000/', 'http://localhost:3000/' ]
  1. Remove the withPayload HOC from next.config.ts

  2. Run again check-redirects": "tsx scripts/checkRedirects.ts, you'll see no further redirect

yarn check-redirects
[ 'http://localhost:3000/' ]
Which area(s) are affected? (Select all that apply)

area: core

Environment Info
Binaries:
  Node: 20.18.0
  npm: 10.8.2
  Yarn: 3.8.1
  pnpm: N/A
Relevant Packages:
  payload: 3.46.0
  next: 15.3.5
  @payloadcms/db-mongodb: 3.46.0
  @payloadcms/graphql: 3.46.0
  @payloadcms/next/utilities: 3.46.0
  @payloadcms/richtext-lexical: 3.46.0
  @payloadcms/translations: 3.46.0
  @payloadcms/ui/shared: 3.46.0
  react: 19.1.0
  react-dom: 19.1.0
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:49 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 10

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproduction repository, run the check-redirects script, and compare the behavior with and without withPayload in next.config.ts. Then trace the relevant Payload Next utilities and confirm the fix by ensuring the root URL is reported once rather than as a same-URL redirect while retaining its 200 response.

Written by the indexing model from the issue text.

Assessment

Tech stack
nextjs, typescript
Domain
backend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.