Next.js 16 Server Actions Cross-Origin Requests Rejected? How to Troubleshoot a Reverse Proxy (2026)
A Server Action fails only after deployment behind a proxy, while the same form works locally.
Fastest safe fix: compare the browser’s Origin with the Host received by Next.js, and trace whether the request reaches the application. Add serverActions.allowedOrigins only when a legitimate cross-origin path remains and the proxy chain is confirmed; do not use it to conceal a broken Host-forwarding rule.
This guide is for frontend engineers maintaining Next.js 16 App Router applications behind a reverse proxy, gateway, or multiple domain entry points.
Platform engineers can use it to check forwarded request headers along the proxy chain.
Application security owners and release testers can use it to keep any additional trusted origins narrow and verifiable.
Start with the failing request, not the error label
A browser message that sounds like a cross-origin failure does not, by itself, establish that the browser’s CORS policy blocked the request. Server Actions have their own request handling and origin checks. A proxy can also reject or rewrite a request before it reaches Next.js, while the application can receive a valid request and then fail inside its action logic.
Start with the browser’s Network panel. Submit the form once, select the failed Action request, and record the request URL, method, Origin, request Host where visible, response status, and response body. Redact cookies, authorization values, session identifiers, and other secrets before sharing the capture. Do not treat the presence of a generic browser error as proof that the request never reached the server.
Then correlate the browser evidence with logs at each available boundary: the edge or gateway, the reverse proxy, and the Next.js application. The key question is where the request stops:
- No matching request at the edge: check the browser URL, DNS, client-side routing, or an upstream network rule.
- The edge records it, but Next.js does not: investigate proxy routing, request filtering, method handling, and upstream connectivity.
- Next.js receives it and rejects the source: compare the request’s
Originand theHostvalue seen by the application, then verify the configured allowlist. - Next.js accepts the request but the action fails: inspect the action’s validation, authentication, authorization, and application logs. That is not evidence of an origin-check failure.
The official Server Actions security guidance describes the origin check as a security boundary. The data mutation documentation describes Server Actions as invoked through POST requests. That distinction helps narrow the investigation: confirm the actual request and its response before changing unrelated client state, cache, or CORS settings.
Check the browser caller and deployed URL
Why does Next.js 16 reject a Server Action source?
The browser sends an Origin header that identifies the origin making the request. An origin is defined by its scheme, host, and port; a difference in any of those components can make two URLs distinct origins. See the MDN reference for the Origin header.
Compare these values from the failing submission:
- The page URL shown in the address bar.
- The Action request URL shown in the Network panel.
- The request’s
Originheader. - The host name the application receives, as recorded at the proxy or application boundary.
Do not compare only the visible domain names. A page served over HTTPS and a request sent over HTTP differ by scheme. A preview hostname and a production hostname differ by host. A non-default port can also matter. Capture the real values rather than guessing from environment names such as “preview” or “production.”
If the browser sends an origin that does not match the host Next.js sees, determine whether the mismatch is expected by the deployment topology. For example, a browser may address a public application hostname while an upstream proxy forwards the request to an internal service name. That internal name should not automatically become the basis for a broad trust rule. First identify which values are present at the public edge, after each proxy, and at the application.
A local success does not settle the production case. Local development may use one host and a direct connection, while a preview environment may add a different hostname or an extra proxy hop. Production can also terminate TLS at the edge and forward requests over an internal connection. Those differences are enough to change what the application sees, even when the form code is identical.
Why can the error appear only in production?
Treat an environment-only failure as evidence of a request-path difference, not as proof of a Next.js cache problem. A production-only error commonly narrows the investigation to deployed hostnames, TLS termination, gateway rules, header forwarding, or production configuration. It does not identify which one is responsible.
Compare the working and failing request captures side by side. Keep the same Action and form data where practical, but redact secrets. Check whether the deployed page uses a different scheme, whether the browser targets a different hostname, and whether the production edge alters headers or routes the request to a different upstream. If a preview domain succeeds while the production domain fails, verify both domains’ actual request paths rather than copying the preview configuration into production without review.
Also separate source validation from unrelated symptoms. A stale screen after a successful submission points toward rendering or data revalidation. A client component losing local state is a client-side state problem. A request rejected before the action runs is a different failure class. Do not infer that revalidatePath, caching, or client state caused a source rejection unless the logs show the request passed the origin check and reached that logic.
Reconstruct what the proxy forwards
What should you do when Origin and Host differ after a reverse proxy?
The browser’s Origin describes the caller’s origin. Host identifies the host used for the request at the receiving boundary. A reverse proxy may change, preserve, or omit host-related values as it forwards traffic. A forwarded-host header can carry the original host information, but its meaning depends on the proxy chain and application configuration; see MDN’s X-Forwarded-Host reference.
Trace the headers at each boundary instead of assuming that one proxy setting explains the entire request. Record the public request values at the edge, the forwarded values after each proxy, and the values visible to Next.js. Depending on the deployment, useful fields may include Host, Origin, X-Forwarded-Host, and the forwarded protocol. Do not publish raw authentication or cookie headers in a ticket or support request.
The Next.js self-hosting guidance covers deployment considerations for applications behind a reverse proxy. Use it alongside your actual proxy configuration. A gateway and an upstream reverse proxy may each apply their own header rules, so checking only the last proxy’s settings can leave an earlier rewrite undiscovered. The HTTP specification also defines a gateway as an intermediary that acts as an origin server for a connection while forwarding requests; this is why the HTTP semantics specification is relevant when reconstructing a multi-hop request path.
Use a direct-versus-proxied comparison to isolate the layer:
- Direct request succeeds; proxied request fails: prioritize proxy routing and header forwarding.
- Both requests reach Next.js with the same relevant headers and both fail: inspect application configuration and the documented origin-check behavior.
- The proxy returns the failure before Next.js logs the request: investigate gateway policy, filtering, and upstream routing.
- Next.js logs the request and the action’s own code reports an error: investigate application validation or authorization rather than changing the source allowlist.
This comparison does not require a permanent change to production routing. Use a controlled test environment or a temporary, access-restricted diagnostic route where appropriate. Keep the test equivalent enough to reveal the header difference, and remove any temporary exposure when the investigation ends.
Decide whether allowedOrigins is necessary
Should allowedOrigins contain the browser domain or the proxy domain?
Use the current Next.js Server Actions configuration reference for the exact semantics supported by the deployed Next.js version. The setting is for adding allowed origins to the Server Actions origin check; it is not a general-purpose CORS switch and does not repair incorrect proxy forwarding.
When a legitimate browser origin differs from the host seen by Next.js because of a confirmed deployment design, serverActions.allowedOrigins may be appropriate. The values should reflect the expected public origins that actually need to call the application under that design. Do not add an internal upstream name merely because it appears in a log, and do not add a proxy hostname automatically: first establish which host and origin values are compared and why they differ.
The configuration belongs to the application’s Next.js configuration, using the structure documented for the installed version. For example, the conceptual allowlist should contain only an explicitly approved application origin:
const nextConfig = {
experimental: {
serverActions: {
allowedOrigins: ['actions.example.com'],
},
},
};
module.exports = nextConfig;
Treat this snippet as a shape to validate against the documentation for the exact Next.js release and build configuration in use, not as a universal drop-in fix. Confirm that the deployed build loads the intended config. A local config file that is not included in the production build does not change production behavior.
Use this decision comparison before editing the allowlist:
| Option | Use it when | Main risk or limitation |
|---|---|---|
| Correct proxy forwarding | Next.js receives a rewritten, missing, or unexpected Host value |
Requires tracing every proxy hop; a partial fix can leave another environment broken |
Add a narrow allowedOrigins entry |
A legitimate cross-origin deployment path is confirmed and the proxy behavior is intentional | Expands the set of origins trusted for Server Actions; an overly broad entry weakens the boundary |
| Change CORS policy | The browser console and response headers show a separate cross-origin browser-policy issue | CORS changes do not automatically fix a Server Actions origin-check rejection |
| Change cache or client state code | Logs show the request passed source validation and the failure occurs during rendering or action logic | Irrelevant changes can mask the real source mismatch while leaving the request rejected |
The safest default is to repair a wrong or inconsistent proxy header. Add an allowlist entry only when the mismatch is legitimate, understood, and required by the deployment. Avoid broad wildcards unless the official documentation for the deployed version supports the intended pattern and the security owner has reviewed the full set of names it can match.
A successful submission after widening the allowlist proves only that the request now passes that check. It does not prove the resulting trust boundary is appropriate.
Assign checks to the people who own each boundary
Browser caller. Confirm the page and Action request URLs, then capture the Origin and response details from the failed request. Check local, preview, and production hostnames independently. If the browser points to an unexpected endpoint, resolve that routing or environment-selection issue before changing server trust settings.
Proxy and platform maintainer. Follow the request from the public edge to the Next.js process. Verify that the proxy forwards the expected host information and protocol, and check whether another gateway modifies those values earlier in the chain. The HTTP gateway definition is useful context, but the actual forwarded headers and proxy configuration are the evidence for a specific deployment.
Application security owner. Review whether a cross-origin call is required at all. If it is, approve only the origins justified by the deployment and check that the application still enforces authentication and authorization within the action. Next.js’s authentication guidance distinguishes authentication from authorization; passing an origin check should not be treated as proof that a caller may perform the requested operation.
Release tester. Test the expected public entry point after deployment, then test an origin that should not be trusted. Check both the request result and the application or proxy logs. Save a redacted before-and-after capture so a future configuration change can be compared against known behavior.
Use a release checklist that tests the trust boundary
Before deploying a change, verify each item that applies:
- [ ] The failing request is identified in the browser Network panel, with its URL,
Origin, method, response status, and safe-to-share response details recorded. - [ ] Proxy and application logs establish whether the request reached Next.js.
- [ ] The public host, forwarded host values, and host received by the application are documented for the failing path.
- [ ] The team has classified the issue as proxy interception, source validation, browser CORS policy, or application logic rather than treating those as interchangeable.
- [ ] Any
serverActions.allowedOriginschange matches the verified deployment topology and the configuration syntax for the installed Next.js version. - [ ] The intended public origin can submit the Action after deployment.
- [ ] An origin that should not be trusted remains rejected.
- [ ] Preview and production hostnames are tested separately, with redacted request evidence retained for review.
A single successful response is not enough to validate a security configuration. The release check must show that the intended caller works and that an unapproved caller has not gained access as a side effect. If the failure returns after a proxy or platform change, compare the saved headers rather than repeating an earlier allowlist expansion.
Choose a test environment that matches the question
A local developer machine is often enough to validate the action code, but it may not reproduce the production gateway’s host rewriting or TLS termination. A production-only test can expose the real path, but it also makes diagnosis harder when the team cannot safely change routing or capture the relevant headers. A separate client-testing environment can help reproduce browser behavior and compare entry points, but it does not replace a server environment that mirrors the production proxy chain.
For a temporary investigation, KuzCloud may be relevant when the team needs an isolated Mac environment for browser-side or cross-device validation. That environment should be treated as an aid to client testing, not as a substitute for the production reverse proxy or a Linux server topology. Teams evaluating whether a separate environment fits their workflow can review the KuzCloud console and its help resources; neither removes the need to verify the actual Origin, forwarded Host, and application logs on the deployment path.
If the current setup depends on one developer’s laptop, it can be difficult to reproduce the same browser session or keep test conditions separate. If every investigation must use production, changing headers to diagnose a failure carries avoidable operational risk. A rented Mac can improve isolation for temporary client-side validation, while a production-like proxy test remains necessary for server-side source checks. For teams that already have reproducible local browsers and a safe staging gateway, renting hardware may add little value; for teams that need a short-lived, separate test workstation, it can be a better fit than expanding production trust settings just to make a failing Action submit.
Validate Your Proxy Setup on a Dedicated Mac
Provision a dedicated KuzCloud Mac mini and get SSH or VNC credentials in minutes.
Test reverse-proxy routing, forwarded host and origin handling, and Server Actions from a real remote environment.