cloudflare-worker-router icon indicating copy to clipboard operation
cloudflare-worker-router copied to clipboard

When using middleware how do you use the body multiple times in each middleware?

Open kalepail opened this issue 1 year ago • 1 comments

I'm getting the error Body has already been used. It can only be used once. Use tee() first if you need to read it twice.

Normally you'd use req.clone or res.clone but clone doesn't appear to exist on req or res for this library.

kalepail avatar Dec 07 '23 15:12 kalepail

I've added some tests for this behavior, and they pass, can you please retest with the current version v3.3.4?

Tests: https://github.com/tsndr/cloudflare-worker-router/blob/306c046adb3fed3dbdd4df0787476edf001539fa/tests/index.spec.ts#L296-L365

tsndr avatar Jan 20 '24 22:01 tsndr