You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This typical Cloudflare code to modify a request (such as changing the url) fails when withParams is used
with the error Incorrect type for the 'fetcher' field on 'RequestInitializerDict': the provided value is not of type 'Fetcher'
import{Router,typeIRequest,withParams}from'itty-router';constrouter=Router<IRequest,CFArgs>({before: [withParams],});router.get('*',(request)=>{constreq=newRequest('https://example.com',request);// <-- fails with Incorrect type for the 'fetcher' field on 'RequestInitializerDict': the provided value is not of type 'Fetcher'.// ... change req headers etc });exportdefault{ ...router};
Describe the Issue
This typical Cloudflare code to modify a request (such as changing the url) fails when
withParams
is usedwith the error
Incorrect type for the 'fetcher' field on 'RequestInitializerDict': the provided value is not of type 'Fetcher'
The issue is this line https://github.com/kwhitley/itty-router/blob/v5.x/src/withParams.ts#L6
as seems like workerd is already wrapping request with rpc object and it has RPCBlabla type with bind method of the same type.
If bind is really needed better to check that
obj[prop] instanceof Function ? obj[prop].bind ....
Fails in dev and production (when published to cloudflare)
The text was updated successfully, but these errors were encountered: