ra
ra
CDCloudflare Developers
Created by ra on 8/6/2024 in #workers-help
Cloudflare Worker for API endpoint returning Cloudflare error page
No description
9 replies
CDCloudflare Developers
Created by ra on 4/6/2023 in #workers-help
Workers_Trace_events and Logpush via HTTP
Following the docs, I'm using the following command to enable logpush:
curl -s -X POST 'https://api.cloudflare.com/client/v4/accounts/<my-account>/logpush/jobs' -X POST -d '
{
"name": "canopy-api-logpush",
"output_options": {
"field_names": ["Event", "EventTimestampMs", "Outcome", "Exceptions", "Logs", "ScriptName"],
"timestamp_format": "rfc3339",
"sample_rate": 1.0
},
"destination_conf": "https://in.logtail.com?header_Authorization=Bearer%20<my-token>&header_content-type=application%2Fjson",
"max_upload_bytes": 5000000,
"max_upload_records": 1000,
"dataset": "workers_trace_events",
"enabled": true
}' -H "X-Auth-Email: <my-email>" -H "X-Auth-Key: <my-auth-key>"
curl -s -X POST 'https://api.cloudflare.com/client/v4/accounts/<my-account>/logpush/jobs' -X POST -d '
{
"name": "canopy-api-logpush",
"output_options": {
"field_names": ["Event", "EventTimestampMs", "Outcome", "Exceptions", "Logs", "ScriptName"],
"timestamp_format": "rfc3339",
"sample_rate": 1.0
},
"destination_conf": "https://in.logtail.com?header_Authorization=Bearer%20<my-token>&header_content-type=application%2Fjson",
"max_upload_bytes": 5000000,
"max_upload_records": 1000,
"dataset": "workers_trace_events",
"enabled": true
}' -H "X-Auth-Email: <my-email>" -H "X-Auth-Key: <my-auth-key>"
When executing the following command, I'm getting the following error: {"errors":[{"code":1002,"message":"error parsing input: invalid JSON syntax"}],"messages":[],"result":null,"success":false} It doesn't appear to be anything wrong with my input (chat gpt agrees 😆 )
27 replies
CDCloudflare Developers
Created by ra on 2/1/2023 in #workers-help
Worker Logs not showing up via tail or in dashboard
My worker looks like the following:
export default {
async fetch(
request: Request,
env: Env,
ctx: ExecutionContext
): Promise<Response> {
console.log("Starting req.");
// logic
}
export default {
async fetch(
request: Request,
env: Env,
ctx: ExecutionContext
): Promise<Response> {
console.log("Starting req.");
// logic
}
The console.log statement is on the very first line of the fetch handler, and I'm not able to see logs via wrangler tail --env production or in the dashboard. Any ideas what could be going wrong here? I am able to view the logs with wrangler dev but I am not able to view the logs at all in production.
1 replies