payloadcms / payloadcms/payload
[Next Combined] Unwanted internal redirection with HOC - SEO Impact
Nobody has claimed this yet.
- 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:
- Run
check-redirects": "tsx scripts/checkRedirects.ts, you'll see the page being redirected
yarn check-redirects
[ 'http://localhost:3000/', 'http://localhost:3000/' ]
-
Remove the
withPayloadHOC fromnext.config.ts -
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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