Missing origin
header from a forwarded Server Actions request.
#58646
Replies: 19 comments 8 replies
-
Same issue here using Next v14.0.3. Here's the output with the included stack trace:
|
Beta Was this translation helpful? Give feedback.
-
Same issue here, not using any server actions. No files with "use server" directive. The query is a fetch call from React Query v5. Works on most if not all devices. Only some users have reported the fetch request failing. Next v14.0.3. |
Beta Was this translation helpful? Give feedback.
-
Same issue, Next v14.0.3. |
Beta Was this translation helpful? Give feedback.
-
I got that issue too.
|
Beta Was this translation helpful? Give feedback.
-
My workaround for this at the moment is to use next version 13.4.12. Versions beyond this have some other major issues #56018 which may be related. |
Beta Was this translation helpful? Give feedback.
-
I think it's just a bad error message in production. I got this error when I switched one of my api routes from the pages router to the app router. Turns out I didn't account for the pages version supporting both const contentType = request.headers.get('content-type')
if (!contentType?.includes('application/json')) {
return new Response('Invalid content type. JSON expected.', { status: 400 })
} But you could also support both: const contentType = request.headers.get('content-type')
let something
if (contentType?.includes('application/x-www-form-urlencoded')) {
const formData = await request.formData()
something = formData.get('something')
} else if (contentType?.includes('application/json')) {
const json = await request.json()
something = json.something
} else {
return new Response('Invalid content type', { status: 400 })
}
console.log(something) // something is now defined |
Beta Was this translation helpful? Give feedback.
-
This happens to me on a api route defined in route.tsx. I called it from insomnia and I see this. |
Beta Was this translation helpful? Give feedback.
-
I use Nginx as a proxy. I also received similar messages from time to time. Also, |
Beta Was this translation helpful? Give feedback.
-
I've got the
I haven't located anything in the browser sending a Edit: Running Next 14.0.4 |
Beta Was this translation helpful? Give feedback.
-
This happens to me on a standard app-directory page.ts that was expecting a standard GET request. A third party makes a POST request instead. Making a POST request with content-type: application/json seems fine but content-type: application/x-www-form-data-urlencoded causes "Missing |
Beta Was this translation helpful? Give feedback.
-
I solved my issue like this I tried to redirect user after post request |
Beta Was this translation helpful? Give feedback.
-
I have the same issue too, even upgrading to release versions causes weird problems. |
Beta Was this translation helpful? Give feedback.
-
Im seeing a lot of these but can't figure out what's causing it |
Beta Was this translation helpful? Give feedback.
-
Also having this in production on an API endpoint not triggered by any Server Action (as I did not implement any on my project) |
Beta Was this translation helpful? Give feedback.
-
I have one that's reproducible. I have a form that is being sent to a route handler. That form has an I found out, that any query param added to the form action will make it fail and cause the server action error. Superweird! |
Beta Was this translation helpful? Give feedback.
-
Same issue, not sure how to fix using Next 14.1.0 |
Beta Was this translation helpful? Give feedback.
-
Add this to header and try again. It worked for me:
|
Beta Was this translation helpful? Give feedback.
-
where should I exactly add this? this is my next.config.mjs: export default nextConfig; |
Beta Was this translation helpful? Give feedback.
-
This happens when the incoming request to the app, especially a POST call doesn't have the correct origin header set in it or your application is always assuming the content type in the incoming request is application/json and some 3rd party app or client (postman/insomnia or some tester) trying to call your app by sending some weird payload or content type, and your application assumes it as a json payload. It is under these circumstances, this error pops up. I had a similar issue and I addressed by adding an entry in my
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
I'm running nextjs 13.5.6 standalone server via dokku. After a few minutes of running in production, I'm seeing a flood of these messages.
Next also begins to return blank white pages with an HTTP 304 status.
I'm confused here. What is a forwarded Server Actions request and why is it missing a header?
EDIT
I read this page-- https://nextjs.org/docs/app/api-reference/functions/server-actions To my knowledge, I am not using any Server Actions.
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions