Fukada
05/11/2023, 3:49 PMurOpinion > /dev/null
05/12/2023, 12:38 PMimport Tesseract from "tesseract.js";
const recognizeText = async () => {
try {
const { data } = await Tesseract.recognize(
"https://tesseract.projectnaptha.com/img/eng_bw.png",
"eng"
);
return data.text;
} catch (err) {
return "Hello world! " + err;
}
};
export default {
async fetch(request, env, ctx) {
const text = await recognizeText();
return new Response(text, {
headers: { "content-type": "text/plain" },
});
},
};
And here is an image of the local dev server.
Thanks in advance for any help!
https://cdn.discordapp.com/attachments/1106561137958453269/1106561138730209290/image.png▾
redux1997
05/12/2023, 5:32 PMoooyeee
05/13/2023, 12:17 PMLeokratis
05/13/2023, 6:38 PMwebsite2.com
under the`website.com/2` domain and so far I have managed to do that using the code:
js
export default {
async fetch(request) {
async function MethodNotAllowed(request) {
return new Response(`Method ${request.method} not allowed.`, {
status: 405,
headers: {
Allow: "GET",
},
});
}
// Only GET requests work with this proxy.
if (request.method !== "GET") return MethodNotAllowed(request);
return fetch(`https://example.com`);
},
};
It works fine but the assets are not loading and I get the plain html version of the website.
I have setup the following worker routes:
- *dreamcafe.eu.org/assets/images*
- *dreamcafe.eu.org/assets*
- https://dreamcafe.eu.org/guides/
with the *dreamcafe.eu.org/assets*
route it should make the website appear as normal but it doesn't does anyone know why?
https://cdn.discordapp.com/attachments/1107014041911689277/1107014208769499166/image.png▾
schwartzmj
05/13/2023, 8:44 PMmooon
05/13/2023, 9:46 PMscfinan
05/14/2023, 7:33 PMform-data
to construct the payload. The test code below:
https://cdn.discordapp.com/attachments/1107390359266394135/1107390359383842969/Screenshot_2023-05-14_at_3.31.57_PM.png▾
dkfdkdodkms
05/15/2023, 12:16 AMasync fetch(request:Request, env:Env, context:ExecutionContext):Promise<Response>
{
let response = new Response('{}');
response.headers.set('Access-Control-Allow-Headers', 'Content-Type, X-Json');
response.headers.set('Access-Control-Allow-Origin', '*');
response.headers.set('Access-Control-Allow-Methods', 'POST, GET, OPTIONS');
response.headers.set('Access-Control-Max-Age', '86400');
return response;
}
The above works fine with requests without a body. When I add a body to the request the request is stuck in 'pending' status. Just adding this options.body = body;
causes the issue.
Accept:
*/*
Accept-Encoding:
gzip, deflate, br
Accept-Language:
en-US,en;q=0.9
Cache-Control:
no-cache
Connection:
keep-alive
Content-Length:
1780366
Content-Type:
application/octet-stream
Host:
127.0.0.1:8081
Origin:
http://localhost
Pragma:
no-cache
Referer:
http://localhost/
Sec-Ch-Ua:
"Google Chrome";v="113", "Chromium";v="113", "Not-A.Brand";v="24"
Sec-Ch-Ua-Mobile:
?0
Sec-Ch-Ua-Platform:
"macOS"
Sec-Fetch-Dest:
empty
Sec-Fetch-Mode:
cors
Sec-Fetch-Site:
cross-site
User-Agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36
tvargas
05/15/2023, 6:28 AMlasseschou
05/15/2023, 7:22 AMwilbo007
05/15/2023, 1:59 PMPeterMbanugo
05/15/2023, 2:33 PMBamboo
05/16/2023, 2:01 AMIrantwomiles
05/16/2023, 2:45 AMzone.worker.dev
. I've followed the docs and I have the custom route added, but the custom route just redirects back to the original zone.worker.dev
route. How do I prevent this?
Here is my wrangler.toml files:
workers_dev = false
route = "sub.customroute.com/*"
BallAche
05/16/2023, 3:07 AMgookie
05/16/2023, 11:02 AMcf-connecting-ip
header.
I enabled Remove visitor IP headers
in the transform rules but the REST API servers still got the cf-connecting-ip
header in the request.
Then I made a new modify request header rule like attached images shows but the REST API servers still got the cf-connecting-ip
header.
What am I doing wrong?
https://cdn.discordapp.com/attachments/1107986464396025926/1107986464530239559/image.png▾
Danish Waqad
05/16/2023, 11:39 AMzarg129
05/16/2023, 12:20 PMkrondor
05/16/2023, 6:36 PMwrangler dev
in my wrangler.toml
DJtheRedstoner
05/16/2023, 8:20 PM@cloudflare/workers-types@next
and I can't seem to find any typings for it. Adding the following to types.d.ts
works: ts
declare module "cloudflare:sockets" {
export function connect(address: SocketAddress | string, options?: SocketOptions): Socket
}
Bamboo
05/17/2023, 3:48 AMAdvany
05/17/2023, 9:28 AMMoritz S
05/17/2023, 12:03 PMAriful
05/17/2023, 1:07 PMhttps://cdn.discordapp.com/attachments/1108380350826168320/1108380351358832650/Screenshot_from_2023-05-17_18-57-37.png▾
https://cdn.discordapp.com/attachments/1108380350826168320/1108380351887327292/Screenshot_from_2023-05-17_19-00-20.png▾
https://cdn.discordapp.com/attachments/1108380350826168320/1108380352235442276/Screenshot_from_2023-05-17_19-00-36.png▾
https://cdn.discordapp.com/attachments/1108380350826168320/1108380352541642933/Screenshot_from_2023-05-17_19-01-01.png▾
Kynson
05/17/2023, 1:31 PMwrangler publish --env dev
wrangler.toml:
name = 'foo'
account_id = '<ACC ID>'
main = 'src/index.ts'
workers_dev = false
routes = ["foo.com/_api/*", "www.foo.com/_api/*"]
kv_namespaces = [{ binding = 'CONTENT', id = '<KV ID>', preview_id = '<KV ID>' }]
compatibility_date = '2023-05-16'
[env.dev]
workers_dev = true
kv_namespaces = [ { binding = 'CONTENT', id = '<KV ID>', preview_id = '<KV ID>' }]
Issues faced:
- A new worker was created with the name 'foo-dev' (where foo is the original name of the 'production' worker), instead of adding a new environment to the existing foo worker
- The ''foo-dev' was mapped to all 3 routes i.e. foo.com/_api/\*, www.foo.com/_api/* and foo-dev.foo.workers.dev
Confusion:
- I was once able to publish a worker with 2 different environments without having a new worker being created. Yet I can't find the same way to do so now. (Please see the screenshot. The 'contact' worker has another environment called dev).
I tried the name the 'dev' worker with the same name 'foo' and the original one got overwritten.
- As shown on https://developers.cloudflare.com/workers/platform/environments/#staging-environment-with-workersdev I can set workers_dev
to true so it will only deploy to workers.dev. Yet, the all three routes are mapped to the new dev worker.
I am aware that routes
will be inherited so this might be an expected behaviour, but the documentation seem to be misleading (or maybe I got confused). May I know if there is a way to only deploy my worker to workers.dev for a specific environment.
Thank you for your help!
https://cdn.discordapp.com/attachments/1108386385536229526/1108386386274430976/Screenshot_2023-05-17_at_21.22.27.png▾
Azkars
05/17/2023, 3:13 PMgatsbylabs
05/17/2023, 7:52 PM➜ curl https://example.com -svo /dev/null --tls-max 1.2
* Trying 172.67.75.158:443...
* Connected to gatsby.events (172.67.75.158) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/cert.pem
* CApath: none
* (304) (OUT), TLS handshake, Client hello (1):
} [225 bytes data]
* error:1404B410:SSL routines:ST_CONNECT:sslv3 alert handshake failure
* Closing connection 0
https://cdn.discordapp.com/attachments/1108482207846252574/1108482208005628055/Screen_Shot_2023-05-17_at_12.48.13_PM.png▾
Zac
05/17/2023, 11:48 PMGTP_Jordan
05/18/2023, 5:00 AMconst url = `https://api.cloudflare.com/client/v4/accounts/${ACCOUNT_ID}/gateway/rules/${POLICY_ID}`;
const response = await fetch(url, {
method: 'PUT',
headers: {
'X-Auth-Email': API_EMAIL,
'Authorization': `Bearer ${API_TOKEN}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
action: "block",
enabled: false,
})
});
This code is intended to disable the rule. But when I run it I just get an error:
{
"result": null,
"success": false,
"errors": [
{
"message": "must include at least one condition or expression"
}
],
"messages": []
}
I don't understand what "must include at least one condition or expression" means in this context. I also don't understand what the action
string is supposed to do or how it should be used correctly.
If anyone could help me understand this I would really appreciate it. Thanks!