We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
If you use PayloadCMS 3 in subfolder, for example: https://domain.com/subfolder/admin, you get an error like
Request URL: http://domain.com/api/payload-preferences/locale Request Method: GET Status Code: 404 Not Found
but another requests work fine.
Request URL: http://domain.com/subfolder/api/users/me Request Method: GET Status Code: 200 OK
I found this code where apiRoute configs were missing.
const fetchPreferences = async <T extends Record<string, unknown> | string>( key: string, ): Promise<{ id: string; value: T }> => await fetch(`/api/payload-preferences/${key}`, { credentials: 'include', headers: { 'Content-Type': 'application/json', }, method: 'GET', })?.then((res) => res.json() as Promise<{ id: string; value: T }>)
Working example from another functions:
const request = await requests.get(`${serverURL}${api}/payload-preferences/${key}`, { async function refresh() { try { const request = await requests.post( `${serverURL}${apiRoute}/${userSlug}/refresh-token?refresh`, { headers: { 'Accept-Language': i18n.language, }, }, )
const res = await fetch(`${apiRoute}/payload-preferences${stringifiedQuery}`, { credentials: 'include', headers: { 'Content-Type': 'application/json', }, method: 'DELETE', })
https://github.com/alexdeia/payload-api-route-bug
check next.config.mjs:
const nextConfig = { // Your Next.js config here basePath: '/subfolder' }
check payload.config.ts:
localization: { locales: ['de', 'en'], defaultLocale: 'en', fallback: true },
.env
pnpm dev
http://localhost:3000/subfolder/admin
index.js:4704 GET http://localhost:3000/api/payload-preferences/locale 404 (Not Found)
Just in case, I checked - these settings do not affect the payload-preferences URL
routes: { // admin: '/subfolder/admin', api: '/subfolder/api', },
area: ui
> cross-env NODE_OPTIONS=--no-deprecation payload "info" Binaries: Node: 22.11.0 npm: 10.9.0 Yarn: 1.22.19 pnpm: 9.15.4 Relevant Packages: payload: 3.17.1 next: 15.1.0 @payloadcms/db-postgres: 3.17.1 @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: darwin Arch: arm64 Version: Darwin Kernel Version 24.2.0: Fri Dec 6 19:01:59 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T6000 Available memory (MB): 16384 Available CPU cores: 8
The text was updated successfully, but these errors were encountered:
serverURL
routes.api
@r1tsuu same problem with Relationship field type:
https://github.com/payloadcms/payload/blob/main/packages/ui/src/fields/Relationship/index.tsx#L214 and other places.
const response = await fetch(`${serverURL}${api}/${relation}`, { body: qs.stringify(query), credentials: 'include', headers: { 'Accept-Language': i18n.language, 'Content-Type': 'application/x-www-form-urlencoded', 'X-HTTP-Method-Override': 'GET', }, method: 'POST', })
Sorry, something went wrong.
I think this request works for me:
I set basePath to /payload. Now I see it was fixed #10562 with but not released.
basePath
/payload
5a95237
r1tsuu
Successfully merging a pull request may close this issue.
Describe the Bug
If you use PayloadCMS 3 in subfolder, for example: https://domain.com/subfolder/admin, you get an error like
but another requests work fine.
I found this code where apiRoute configs were missing.
Working example from another functions:
Link to the code that reproduces this issue
https://github.com/alexdeia/payload-api-route-bug
Reproduction Steps
check next.config.mjs:
check payload.config.ts:
.env
pnpm dev
http://localhost:3000/subfolder/admin
Just in case, I checked - these settings do not affect the payload-preferences URL
Which area(s) are affected? (Select all that apply)
area: ui
Environment Info
The text was updated successfully, but these errors were encountered: