Next.js Discord

Discord Forum

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

Answered
Horned oak gall posted this in #help-forum
Open in Discord
Horned oak gallOP
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 Horned oak gall
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

Horned oak gallOP
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.
Horned oak gallOP
Yes but the header "next-action" isn't explicitly set anywhere either
Horned oak gallOP
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