Next.js Discord

Discord Forum

In server action, I can't obtain header information.

Unanswered
Masai Lion posted this in #help-forum
Open in Discord
Masai LionOP
I want to obtain headers information in server actions
However, it return null in server environments.

I tried to log header information in server actions.
import { headers } from 'next/headers';

export async function createFolder(_: FolderCreateState, formData: FormData) {
  console.log(headers());
  // ..
}


In the console in server show following.
_HeadersList {
  cookies: null,
  [Symbol(headers map)]: Map(0) {},
  [Symbol(headers map sorted)]: null


I want to get origin by headers().get("origin") but it is null..

How can I obtain origin information in server actions?

0 Replies