Skip to content

Instantly share code, notes, and snippets.

@jimmont
Created March 18, 2025 03:58
Show Gist options
  • Save jimmont/8c743fd8f6bff39b6b339c99105a84a6 to your computer and use it in GitHub Desktop.
Save jimmont/8c743fd8f6bff39b6b339c99105a84a6 to your computer and use it in GitHub Desktop.
cloudflare worker POST body missing (always)
export default {
async fetch(req, env, ctx) {
let text = '-text-';
const { url, method } = req;
if(req.method==='POST'){
text = await req.text();
console.log(`req>`, {url, method, text});
debugger;
}
return new Response(`
${ method } ${ url }
text (${ text.length }): ${ text }
§
`, {headers: {'Content-Type':'text/plain; charset=utf-8'}});
},
};
<!doctype html>
<html><body><form method=POST action="/api/blah" enctype="text/plain">
<input name=hello value="world">
<button>submit</button>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment