Hi, I’m trying to update the user first name and last name via a Server Action in NextJS deployed on vercel.
This happens after a user authenticated and received both a session and a refresh token
Locally I have no issue doing that, it’s working nicely. While deployed on production, this code:
const me = await directus.request(updateMe({ first_name: data.firstName, last_name: data.lastName }));
fails with the error
{
errors: [ { message: 'Invalid user credentials.', extensions: [Object] } ],
response: Response {
status: 401,
statusText: 'Unauthorized',
headers: Headers {
date: 'Fri, 25 Jul 2025 15:43:09 GMT',
'content-type': 'application/json; charset=utf-8',
'content-length': '96',
connection: 'keep-alive',
server: 'cloudflare',
...
I’m refreshing the token just right before the request. My client is setup like this
const client = createDirectus(process.env.NEXT_PUBLIC_BASE_URL as string)
.with(authentication('json', { credentials: 'include', autoRefresh: false }))
.with(rest({ credentials: 'include' }))
.with(graphql({ credentials: 'include' }));
logging await directus.getToken() locally returns the token, on Vercel Server Action returns null.
any ideas?