Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next.js rewrites configuration is not working from 3.16.0 #10655

Closed
smoothdvd opened this issue Jan 18, 2025 · 1 comment · Fixed by #10759
Closed

Next.js rewrites configuration is not working from 3.16.0 #10655

smoothdvd opened this issue Jan 18, 2025 · 1 comment · Fixed by #10759
Assignees

Comments

@smoothdvd
Copy link

Describe the Bug

the setting in next.config.mjs is not take effect:
the issue is affect the version from 3.16-3.17.x

async rewrites() {
  return [
    {
      source: '/api/v1/ai/user-works/:path',
      destination: '/api/user-works/:path',
    },
  ]
}
Image

Link to the code that reproduces this issue

https://github.com/smoothdvd/payloadcms-nextjs-rewrites-issue

Reproduction Steps

  • pnpx create-payload-app@latest -t blank
  • add a UserWorks collection
  • add a rewrites configuration in next.config.mjs
import { withPayload } from '@payloadcms/next/withPayload'

/** @type {import('next').NextConfig} */
const nextConfig = {
  // Your Next.js config here
  async rewrites() {
    return [
      {
        source: '/api/v1/ai/user-works/:path*',
        destination: '/api/user-works/:path*',
      },
    ]
  }
}

export default withPayload(nextConfig)
curl http://localhost:3000/api/v1/ai/user-works

{"message":"Route not found \"/api/v1/ai/user-works\""}

Which area(s) are affected? (Select all that apply)

area: core

Environment Info

Binaries:
  Node: 20.18.1
  npm: 10.8.2
  Yarn: 1.22.22
  pnpm: 9.15.0
Relevant Packages:
  payload: 3.17.1
  next: 15.1.0
  @payloadcms/email-nodemailer: 3.17.1
  @payloadcms/graphql: 3.17.1
  @payloadcms/next/utilities: 3.17.1
  @payloadcms/payload-cloud: 3.17.1
  @payloadcms/richtext-lexical: 3.17.1
  @payloadcms/translations: 3.17.1
  @payloadcms/ui/shared: 3.17.1
  react: 19.0.0
  react-dom: 19.0.0
Operating System:
  Platform: linux
  Arch: x64
  Version: #26~22.04.1-Ubuntu SMP Thu Jul 11 22:33:04 UTC 2024
  Available memory (MB): 7930
  Available CPU cores: 2
@smoothdvd smoothdvd added status: needs-triage Possible bug which hasn't been reproduced yet validate-reproduction labels Jan 18, 2025
@r1tsuu r1tsuu self-assigned this Jan 23, 2025
@github-actions github-actions bot removed the status: needs-triage Possible bug which hasn't been reproduced yet label Jan 23, 2025
Copy link
Contributor

🚀 This is included in version v3.19.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants