Created
March 18, 2025 03:58
-
-
Save jimmont/8c743fd8f6bff39b6b339c99105a84a6 to your computer and use it in GitHub Desktop.
cloudflare worker POST body missing (always)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'}}); | |
}, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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