Hi, im using Cloudflare Workers with Fauna.
i have issue when use fauna client with local dev.
// not work
const faunaClient = new faunadb.Client({
secret: 'secret',
scheme: 'http',
domain: 'localhost',
port: 8443,
fetch: customFetch
})
// no issues
const faunaClient = new faunadb.Client({
secret: 'super_secret_key',
fetch: customFetch
})
//
No error message to debug.
Any help is welcome.
ewan
May 21, 2021, 3:49pm
2
Is the Fauna Dev Docker image up and running? Can you share the command that you use to start the Docker image?
Is your “not work” example running on Cloudflare? If so, localhost
would (likely) refer to that Cloudflare host, not your local machine.
Is your “not work” example running on Cloudflare?
No, running local using wrangler dev
Can you share the command that you use to start the Docker image?
docker run -d --name faunadb -p 8443:8443 fauna/faunadb
i just want create tests using Fauna Docker Image without use dashboard.fauna to create databases.
my worker is very simple.
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
const result = await faunaClient.query(Add(2, 2))
console.log(result)
return new Response('Hello worker!', {
headers: { 'content-type': 'text/plain' },
})
}
ewan
May 21, 2021, 8:45pm
4
Can you try running a very simple Node.js script to verify that your Docker image is running correctly?
var faunadb = require('faunadb')
var q = faunadb.query
var client = new faunadb.Client({
secret: 'secret',
domain: 'localhost',
port: 8443,
scheme: 'http'
})
client.query(q.Add(1, 1))
.then((res) => console.log(res))
.catch((err) => console.log(err))
If the output is 2
, we can be reasonably certain that the Docker image is executing queries.
Yes! This example works fine! No issues with docker faunadb.
But when use with cloudflare workers fail.
its so simple to reproduce this issue, i created this repository to help.
any help are welcome.
I haven’t tried your repo, but wrangler dev
does not actually run code on your local machine, it just makes it easier to run Cloudflare Worker code without publishing. Here’s a similar issue filed with Cloudflare:
opened 08:54AM - 31 Dec 20 UTC
dev
feature
### 🐛 Bug Report
I am testing workers locally. Worker fetches json from one o… f 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
* operating system:
* output of `rustc -V`:
* output of `node -v`: 12.18.3
* output of `wrangler -V`: 1.12.2
* contents of `wrangler.toml`
```
name = "i18n-example"
type = "webpack"
account_id = "XXXX"
workers_dev = true
route = ""
zone_id = ""
[site]
bucket = "./public"
entry-point = "workers-site"
```
#### 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
bad news.
So Cloudflare Workers is not for me, if i cant test fauna localhost.
thanks @LeviWolfe @ewan
system
Closed
May 27, 2021, 5:17am
9
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.