wrangler dev fetch service from localhost #1706
Comments
When you run So the Cloudflare network would have access to AWS but not localhost. https://blog.cloudflare.com/announcing-wrangler-dev-the-edge-on-localhost/ |
@jbampton Thanks for the quick reply. Is there any workaround to test this using localhost service? |
I was able to work around this by exposing my localhost to the internet using localtunnel:
I then put a setting on dev in my wrangler.toml to set the url localhost is exposed on, and then a bit of logic in the worker to say if the url is set to reroute requests via this:
|
We need this functionality as well. Right now we're about 1 week into using Workers and trying to develop a cloudflare worker in front of an origin server that would move logic to the edge, and takes about 60-70% longer than it should. We waste more time waiting for a new version of the origin server deploy, in order to test the tiniest change on either side, than we actually spend developing our Worker. I get the reasoning behind wanting the 'dev' version to run on cloudflare servers in order to eliminate any inconsistencies between a local simulated runtime, but that's what the whole point of nightly, SIT, and UAT builds. It essentially precludes the use of the fetch and sub-request system as an integral, non-overlapping part of a wholistic solution, and relegates any potential uses of Workers to a "nice-to-have", but not a mission-critical or mandatory part of a solution's architecture. Even in the Starter example Apollo GraphQL Server, which is probably one of the best examples of building a Worker that provides actual business value-add by moving logic to edge, has sub-requests and a fetch back to the origin server. This is an architecture that would have serious business benefits to anyone, specifically, by moving light compute tasks to the CDN edge along with caching of frequent data, while the origin handled more complex tasks such as analytics with a large database, you could dramatically lower origin costs (our main use case.) However, if you were actively developing this GraphQL Starter example with another Apollo origin server at the same time, you would have to redeploy any new change to the Apollo origin server in order to test with the Worker that sits in front of it. This is not a new request either: #901 #1095, #1093, #1047 If it wasn't for the Workers KV and Durable Objects (and its support for WebSockets), we'd go back to Lambda@Edge in a heartbeat (or if AWS were to launch a similar solution.) At least with Lambda@Edge we can use serverless-offline which we currently use for the IoT side of our stack. Even a simple docker for Workers that could run in a CI pipeline and on dev machines would be better than wonky system of localtunnels or temporary dev deployments to the public internet. |
While I have not experienced this exact issue I was also surprised to find that |
I would also like to have a solution to run Cloudflare Workers locally. It wasn't clear to me that This use case is one that I've used before with AWS Lambda (using Sam or Serverless) and is great for testing functions by mocking their dependent services. What is the plan for addressing this? |
@grahamlyons I'd be curious to know if Miniflare will suit your needs for this. https://miniflare.dev/ |
Yes, yes! A thousand times, yes! This looks like it is exactly what I want |
Stay tuned 馃槈 |
For ppl trying to get miniflare to work, you need to set the upstream value to the host's url (of your other app), this can be done either in
|
Thanks for suggesting this feature! Wrangler v1 is now deprecated and support is only being provided for critical updates or security concerns. As such, we are closing this issue. New versions of Wrangler are maintained in the workers-sdk repo. If this is a feature you鈥檇 like to see in wrangler v2+, please feel free to report it in the workers-sdk repo. For more info about wrangler v1 deprecation, please check out our blog post. To get this feature in Wrangler v2+, use |
馃悰 Bug Report
I am testing workers locally. Worker fetches json from one of the service, when the service endpoint is of aws it works fine, but when i switch endpoint to localhost:5000 it stops working and throws error
The Cloudflare domain resolves to a local or disallowed IP address or an IP address not associated with the domain.
Environment
rustc -V
:node -v
: 12.18.3wrangler -V
: 1.12.2wrangler.toml
Steps to reproduce
Use code from https://developers.cloudflare.com/workers/examples/fetch-html and replace
someHost
with any localhost website.What did you expect to see?
Loaded website with all the content
What did you see instead?
Error 1003 Access Denied: Direct IP Access Not Allowed
The text was updated successfully, but these errors were encountered: