https://discord.cloudflare.com logo
Join Discord
Powered by
# workers-discussions
  • b

    Burner

    02/13/2023, 8:02 PM
    anyone else having their cron triggers run twice
  • b

    Burner

    02/13/2023, 8:04 PM
    i only have this trigger ```toml [triggers] crons = ["30 * * * *"] ```but everything is running twice still
  • b

    Burner

    02/13/2023, 8:05 PM
    they started running twice at about 08:30 today
  • b

    Burner

    02/13/2023, 8:15 PM
    Also there wasn't a new deployment causing this, it was between a deployment 6 days ago and one that was 4 or 5 hours ago
  • a

    aa

    02/13/2023, 8:18 PM
    Is there some way to configure logpush to push log entries individually to a logs service (ie datadog)? The way that it groups all console.log() statements inside one "fetch" event is not very useful, and also leads to "trace resource limit exceeded".
  • t

    Taurlon

    02/13/2023, 9:52 PM
    I had the same question.
  • d

    dave

    02/14/2023, 12:42 AM
    not an answer, but if an exception happens after hitting the trace limit with console.log, do you still get to see the exception in logpush?
  • d

    dave

    02/14/2023, 5:39 AM
    If I need to POST more than 100MB, could I avoid a 413 by having my Worker reply with a 307 redirect to non-CF domain?
  • d

    dave

    02/14/2023, 5:39 AM
    I feel like no since the 413 would happen before my Worker even has a chance :/
  • k

    kian

    02/14/2023, 5:42 AM
  • d

    dave

    02/14/2023, 5:44 AM
    Is there any way to get in front of a 413?
  • d

    dave

    02/14/2023, 5:58 AM
    Trying to think of a cleaner solution than requiring the client to first do a fetch to the Worker, generate a presigned S3 URL to return, and having the client POST to that.
  • n

    Noodles

    02/14/2023, 6:07 AM
    Hey all! Just looking for some advice, this may be something simple that I am just missing due to lack of sleep but wanted to reach out. (all data on this site is fake so don't worry about it being public facing) I have created a worker and pages site to work together to manage some KV things. The issue I have right now is that I can pull data from the worker > pages. When I try to do an action by pressing a button on the pages app and sending it back to workers it returns: "has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled." Though I have tried to set the pages _headers file with
    Copy code
    Access-Control-Allow-Origin: *
      Access-Control-Allow-Methods: GET, POST
    and also modified the worker function to include it as well
    response.headers.set('Access-Control-Allow-Origin', '*');
    Example will be from So when I try to click the "disable" button it should do the following and pass along the name/version of the plugin which was in the row of the table the button was clicked on.
    Copy code
    disableButton.addEventListener('click', async () => {
                    const response = await fetch('https://license.bghddevelopment.workers.dev/api/plugins/disable', {
                        method: 'POST',
                        body: JSON.stringify({ name: plugin.name, version: plugin.version }),
                        headers: { 'Content-Type': 'application/json' },
                        mode: 'cors',
                    })
                    const result = await response.json()
                    if (result.success) {
                        enabledCell.textContent = 'No'
                        disableButton.disabled = true
                        enableButton.disabled = false
                    } else {
                        console.error('Failed to disable plugin')
                    }
                })
    Then the worker runs for example this (I know this is enable, disable is the exact same but changed to disable)
    Copy code
    if (pathname === '/api/plugins/enable') {
        console.log(`Enabling plugin: ${pluginName}, version: ${pluginVersion}`);
        const licenseKeyKey = `${pluginName}-${pluginVersion}`;
        const plugin = await LICENSE_KEY_KV.get(licenseKeyKey, { type: 'json' });
        if (!plugin) {
          const response = new Response(`Plugin ${pluginName}, version ${pluginVersion} not found`, { status: 404 });
          response.headers.set('Access-Control-Allow-Origin', '*');
          return response;
        }
        if (plugin.enabled) {
          const response = new Response(`Plugin ${pluginName}, version ${pluginVersion} is already enabled`, { status: 400 });
          response.headers.set('Access-Control-Allow-Origin', '*');
          return response;
        }
        const newPlugin = {...plugin, enabled: true};
        await LICENSE_KEY_KV.put(licenseKeyKey, JSON.stringify(newPlugin));
        const response = new Response(`Plugin ${pluginName}, version ${pluginVersion} enabled`);
        response.headers.set('Access-Control-Allow-Origin', '*');
        return response;
      }
    Hopefully this makes decent sense, any advice is appreciated.
  • k

    kian

    02/14/2023, 6:09 AM
    You need to handle
    OPTIONS
    requests
  • k

    kian

    02/14/2023, 6:10 AM
  • k

    kian

    02/14/2023, 6:11 AM
    That's how to do it with Pages which has method specific handlers - if you're using Workers, then just do the same if the inbound request method is
    OPTIONS
  • n

    Noodles

    02/14/2023, 6:15 AM
    Thanks will check it out
  • n

    nwdles

    02/14/2023, 8:03 AM
    hello everyone! what's to be done to change cf options like format and use it in workers
    let options = { cf: { polish: 'lossless', image: {format: 'webp'} } }
    ? i need to enable speed->optimization->image resizing for any of domains?
  • l

    lasseschou

    02/14/2023, 8:20 AM
    Hello there. I was wondering if Cloudflare stores logs including IP addresses when users browse worker scripts? I'm reading elsewhere that Cloudflare may store logs up to 30 days, including IP addresses, to prevent DDoS attacks. I need to know this because of GDPR, since IP addresses are considered PII. Thanks
  • k

    kian

    02/14/2023, 8:22 AM
    If you have a route or custom domain then it'll be logged same as any other site access - so it'll be available in analytics, or security events if they were blocked, etc
  • l

    lasseschou

    02/14/2023, 8:24 AM
    Ok, thanks. Can anybody by any chance point me to where this log retention policy is described?
  • j

    JatinGundabathula

    02/14/2023, 9:20 AM
    Hi Guys, Need some help here. i want to bypass cache (request should hit the origin ) using https://developers.cloudflare.com/workers/examples/cache-using-fetch/ at the time of fetch what was the best practice to do.
  • h

    HardAtWork

    02/14/2023, 9:22 AM
    Try this tutorial instead, as it gives you more control over when a Request/Response should be cached: https://developers.cloudflare.com/workers/examples/cache-api/
  • j

    JatinGundabathula

    02/14/2023, 9:23 AM
    Thank you for the reply. but we wanted to use fetch api cache option instead of cacheAPI
  • h

    HardAtWork

    02/14/2023, 9:24 AM
    As far as I know, you can set a
    fetch
    to bypass cache next time, but you can't bypass cache on the first request.
  • h

    HardAtWork

    02/14/2023, 9:24 AM
    As in, set a
    cacheTtl
    to 0, which means next time you request it, it will go to the origin.
  • j

    JatinGundabathula

    02/14/2023, 9:28 AM
    I will try this how about not passing cacheKey at all. will this bypass cache
  • h

    HardAtWork

    02/14/2023, 9:31 AM
    No, because if you omit a
    cacheKey
    , CF will just use the Request URL instead.
  • m

    Mees

    02/14/2023, 10:46 AM
    Hey! I was wondering, is it possible to disable the workers.dev name for workers that have a custom domain? If so, how to do it?
  • s

    Skye

    02/14/2023, 10:47 AM
    In your wrangler.toml
    workers_dev = false
1...226822692270...2509Latest