Skip to content

Very strange behavior — Astro POST endpoints not working in Cloudflare #13758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task
jerrytomato opened this issue May 6, 2025 · 1 comment
Open
1 task
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) pkg: cloudflare Related to the Cloudflare adapter

Comments

@jerrytomato
Copy link

jerrytomato commented May 6, 2025

Astro Info

Astro                    v5.7.10
Node                     v23.8.0
System                   macOS (arm64)
Package Manager          bun
Output                   server
Adapter                  @astrojs/cloudflare
Integrations             @astrojs/react

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

None of my post endpoints are working in production. I even have a test file that has two definitions, GET and POST. When I send a POST request, it has a 301 redirect to the GET handler. Huh?????

// src/pages/api/foo.ts
export async function POST() {
  return new Response("🔥 POST HIT", { status: 200 });
}

export async function GET() {
  return new Response("🧊 GET HIT", { status: 200 });
}

And when I remove the GET handler and just send the POST:

// src/pages/api/foo.ts
export async function POST() {
  return new Response("🔥 POST HIT", { status: 200 });
}

It returns a 404. I have followed everything to setup the cloudflare adapter according to spec and it's still failing.

Anyone experience this or know what's causing it?

What's the expected result?

Endpoints should be deployed flawlessly to CloudFlare.

Link to Minimal Reproducible Example

problem is with cloudflare

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label May 6, 2025
@hkbertoson
Copy link

There is some more to this...

I have created a Minimal Repro here. Cloudflare API Testing

You can hit Test API to test it out. Currently, POST,DELETE,PUT,PATCH will all fail. If you turn off CSRF, it will work.

The issue is not with Cloudflare. It is with CSRF.

@florian-lefebvre florian-lefebvre added - P4: important Violate documented behavior or significantly impacts performance (priority) feat: routing Related to Astro routing (scope) pkg: cloudflare Related to the Cloudflare adapter and removed needs triage Issue needs to be triaged feat: routing Related to Astro routing (scope) labels May 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) pkg: cloudflare Related to the Cloudflare adapter
Projects
None yet
Development

No branches or pull requests

3 participants