Comments (4)
What is it?
You’re seeing the wrangler dev issue, described here:
https://itty.dev/itty-router/guides/cloudflare-workers.
What you can do to fix
In your root/index file, destructure your router as part of your export. This strips the Proxy prototype that is intercepting Wrangler/Miniflare's request.
export default { ...router }
What you can do to help
Here's the issue filed with Wrangler team. Please go thumbs up or comment on this thread to spur things along.
What's happening (for the curious)
In local development, Wrangler has introduced a middleware
property on the default export. The problem is, if they find it, they assume it's an array (of middleware) and immediately iterate it without any safety checks/validation.
In itty-router, we use a Proxy
on the prototype chain to intercept unknown properties of routers and map them to route handlers with the given HTTP method. For instance, router.get
maps to GET
, router.foo
to FOO
, etc. So when we export the router directly (perfectly fine in most environments), and Wrangler asks for a middleware
property, itty returns a route handler (a function). When you try to iterate a function, you get the error you've found.
from itty-router.
Perfectly happy to, because I certainly doubt you'll be the last to discover it (until the Wrangler team sorts things out on their end).
from itty-router.
The PR for this has been merged into main on Wrangler... just need to find the release that includes it:
cloudflare/workers-sdk#5420
from itty-router.
You’re seeing the wrangler dev issue, described here https://itty.dev/itty-router/guides/cloudflare-workers.
Good news is, this works fine in production as-is, or likely more helpful to you, you can destructure your export to solve this in local dev.
export default { ...router }
Thanks, the export default { ...router }
is ok , maybe you can keep the issue opened for other user.
from itty-router.
Related Issues (20)
- Typescript router "Additional types" are ignored HOT 10
- Setting up cron trigger? HOT 2
- cors functions are stateful HOT 8
- Nested routers ergonomics HOT 8
- createCors().corsify eats additional Set-Cookie headers HOT 3
- Does `json()` support `headers` in options? HOT 4
- `withContent` returns a 500 when no body is sent HOT 1
- CORS issue, no preflight request shown HOT 6
- PROPOSAL: CORS HOT 4
- multiple set-cookie headers are removed by corsify
- Exception thrown by withContent HOT 5
- Corsify override http error code. HOT 3
- typescript compilation error when using itty-router 5.0.5 HOT 3
- Issue with CORS when response is cached HOT 2
- TS compilation error when using itty-router 5.0.17 HOT 11
- withContent middleware fails on BunJS HOT 1
- Feedbdack on deprecation of router.handle HOT 2
- Requests in v5 are hanging, examples not working HOT 7
- Nesting route cannot handle request for static assets HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from itty-router.