Comments (3)
It is related NextJS error related in vercel/next.js#60552, vercel/next.js#52209 . I think next/headers
, next/cookies
, next/cache
... is not working properly in RSC with itself server API.
from payload.
Hey @sriechersrc — you should try and retrieve cookies with next/cookies
. Does that work?
https://nextjs.org/docs/app/api-reference/functions/cookies
If there is indeed an issue, it seems to be an issue with Next.js though. We do indeed have access to cookies within Payload 3.x and our patterns work accordingly, so I will close this issue and we should track this on the above Next.js issues instead to de-duplicate.
One other note would be that if you are trying to authenticate, you can do that with payload.auth({ headers })
. That might simplify things.
from payload.
Retrieving the cookies via next/cookies
in an API Route seems also to be bugged. But I managed to move the logic to my main page component and dynamically enable draftMode like this:
const isPreview = slugs[slugs.length - 1] === 'preview' // im redirecting to /my-path/preview so I am checking if "preview" exits on the slug
const payload = await getPayload({
config: configPromise,
})
if (isPreview) {
const { headers } = await import('next/headers')
const auth = await payload.auth({ headers: headers() })
if (auth.user) {
draftMode().enable()
slugs.pop() // remove "preview" from the slugs
} else {
draftMode().disable()
}
}
from payload.
Related Issues (20)
- Incorrect req.locale inside access control functions
- "[DEP0040] The punycode module is deprecated" with Node.js 22.4.0 HOT 1
- Mongo collation enabled by default on v2.24.2 HOT 3
- Default values from field config not being set on DB schema in postgres HOT 3
- Hooks hanging indefinitely on create operation to collection with relation back to triggering collection HOT 5
- Mismatching payload dependency versions found: [email protected], @payloadcms/[email protected]
- Integer field (e.g. ID) with contains filter on postgres breaks/crashes the application completely.
- Can’t use payload in `admin.condition` function of field, can’t use async/await, can’t create options for select field dynamically HOT 1
- Duplicate Declaration in src/payload-types.ts HOT 1
- Performance issues with many lexical rich text editors in one document
- Nested localized arrays break db-postgres in v3 beta
- richtext-lexical crushes admin payload v3 HOT 2
- db-postgres : Upgrade v3.0.0-beta.67 -> v3.0.0-beta.69 throws error HOT 4
- Condition should hide field from filter and grid both HOT 1
- Condition should hide field from filter and grid both
- Lexical editor RelationshipFeature ignoring enabledCollections and disabledCollections HOT 1
- Wrong validation of Password field & New Password should be matched with Confirm Password before creating a new User in Payload HOT 1
- Data missing from version comparison when using localization HOT 1
- Setting admin route to "/" causes "/login" to render in infinite loop
- Migrations no longer work correctly
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from payload.