Next.js Discord

Discord Forum

Error: Failed to find Server Action "null". Missing 'next-action' header.

Answered
Baldfaced hornet posted this in #help-forum
Open in Discord
Baldfaced hornetOP
When trying to navigate to a page that pulls back an array of objects and maps them it fails to do so and is throwing this error in the log file. I have added "use server" to my server action file so not sure what is causing this.

const arrayData: Promise<Type[]> = getAllArrayData();

^This is an import where the get method has 'use server' at the top of the file.
Answered by Baldfaced hornet
I'm not sure why this fixes it but I expanded on my get fetch to include some additional settings and it works all of a sudden. Weird this only comes into play during prod builds and not local at all as I would expect it to cause issues locally if it was an issue with the fetch call itself.

const res = await fetch( ${process.env.NEXT_PUBLIC_HADES_URL}/event, {
method: "GET",
cache: "no-cache",
headers: {
"Content-Type": "application/json"
}
})
View full answer

4 Replies

Baldfaced hornetOP
Note this works fine in my local env but after deploying it to stage is when the issues come into play.
Asian black bear
It clearly shows that the server is not receiving the expected header, so you have to check whether a middleware, proxy or something else is filtering it out unintentionally.
Baldfaced hornetOP
Yes but the header "next-action" isn't explicitly set anywhere either
Baldfaced hornetOP
I'm not sure why this fixes it but I expanded on my get fetch to include some additional settings and it works all of a sudden. Weird this only comes into play during prod builds and not local at all as I would expect it to cause issues locally if it was an issue with the fetch call itself.

const res = await fetch( ${process.env.NEXT_PUBLIC_HADES_URL}/event, {
method: "GET",
cache: "no-cache",
headers: {
"Content-Type": "application/json"
}
})
Answer