© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Cloudflare DevelopersCD
Cloudflare Developers•12mo ago•
5 replies
Castio

OpenNext worker apis not working properly in deployed environment

Hello, I have an OpenNext worker, with an api route /api/subscribe. Here is the endpoint:
import { NextResponse } from "next/server"
import { getCloudflareContext } from "@opennextjs/cloudflare";

export async function POST(req: Request) {
  try {
    console.log("POST /api/subscribe");
    console.log("req", req);


    return NextResponse.json({ success: true })
  } catch (error) {
    console.error("Subscription error:", error)
    return NextResponse.json({ error: "Failed to process subscription" }, { status: 500 })
  }
}
import { NextResponse } from "next/server"
import { getCloudflareContext } from "@opennextjs/cloudflare";

export async function POST(req: Request) {
  try {
    console.log("POST /api/subscribe");
    console.log("req", req);


    return NextResponse.json({ success: true })
  } catch (error) {
    console.error("Subscription error:", error)
    return NextResponse.json({ error: "Failed to process subscription" }, { status: 500 })
  }
}

The problem is on local environment everything is fine and the logs are :
POST /api/subscribe
req Request {
  method: 'POST',
  url: 'http://localhost:3000/api/subscribe',
  headers: Headers {
    host: 'localhost:3000',
    connection: 'keep-alive',
    'content-length': '25',
    'sec-ch-ua-platform': '"Windows"',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36',
    'sec-ch-ua': '"Not(A:Brand";v="99", "Google Chrome";v="133", "Chromium";v="133"',
    'content-type': 'application/json',
    'sec-ch-ua-mobile': '?0',
    accept: '*/*',
    origin: 'http://localhost:3000',
    'sec-fetch-site': 'same-origin',
    'sec-fetch-mode': 'cors',
    'sec-fetch-dest': 'empty',
    referer: 'http://localhost:3000/',
    ......
  },
  destination: '',
  referrer: 'about:client',
  referrerPolicy: '',
  mode: 'cors',
  credentials: 'same-origin',
  cache: 'default',
  redirect: 'follow',
  integrity: '',
  keepalive: false,
  isReloadNavigation: false,
  isHistoryNavigation: false,
  signal: AbortSignal { aborted: false }
}
POST /api/subscribe
req Request {
  method: 'POST',
  url: 'http://localhost:3000/api/subscribe',
  headers: Headers {
    host: 'localhost:3000',
    connection: 'keep-alive',
    'content-length': '25',
    'sec-ch-ua-platform': '"Windows"',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36',
    'sec-ch-ua': '"Not(A:Brand";v="99", "Google Chrome";v="133", "Chromium";v="133"',
    'content-type': 'application/json',
    'sec-ch-ua-mobile': '?0',
    accept: '*/*',
    origin: 'http://localhost:3000',
    'sec-fetch-site': 'same-origin',
    'sec-fetch-mode': 'cors',
    'sec-fetch-dest': 'empty',
    referer: 'http://localhost:3000/',
    ......
  },
  destination: '',
  referrer: 'about:client',
  referrerPolicy: '',
  mode: 'cors',
  credentials: 'same-origin',
  cache: 'default',
  redirect: 'follow',
  integrity: '',
  keepalive: false,
  isReloadNavigation: false,
  isHistoryNavigation: false,
  signal: AbortSignal { aborted: false }
}

but the deployed version receives empty request:
POST https://caster-fun.kaspiummage.workers.dev/api/subscribe - Ok @ 3/11/2025, 12:48:57 AM
  (log) POST /api/subscribe
  (log) req {}
POST https://caster-fun.kaspiummage.workers.dev/api/subscribe - Ok @ 3/11/2025, 12:48:57 AM
  (log) POST /api/subscribe
  (log) req {}

you can see the structure in the picture.
I had another api with the same problem, am I doing something wrong?
image.png
Cloudflare Developers banner
Cloudflare DevelopersJoin
Welcome to the official Cloudflare Developers server. Here you can ask for help and stay updated with the latest news
85,042Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Cache from worker not working properly
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
3y ago
Worker Environment
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
17mo ago
Deployed website unable to find environment variables set on Worker
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
3y ago
OpenNext on Worker giving back server errors
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
9mo ago