https://discord.cloudflare.com logo
Join Discord
Powered by
# workers-help
  • I can't access my service bindings with the service workers syntax
    i

    ivarec

    04/25/2023, 1:37 AM
    Hey there, I'm having some issues using
    miniflare
    and the modules syntax, so I'm falling back to service workers. Everything works fine, except that I can't seem to access my service bindings. Here is my
    index.js
    file as a minimal test case:
    Copy code
    js
    addEventListener('fetch', event => {
      event.respondWith(handleRequest(event.request))
    })
    
    async function handleRequest (request) {
      const res = dbg.fetch()
      return new Response(`Hello from gateway -> ${res}`)
    }
    And my
    wrangler.toml
    file:
    Copy code
    toml
    name = "my-worker"
    main = "src/index.js"
    compatibility_date = "2023-04-24"
    
    services = [
      { binding = "dbg", service = "my-debug-service" }
    ]
    
    routes = [
        { pattern = "localhost", custom_domain = true }
    ]
    
    [vars]
    foo = "BAR"
    I can see the following in my logs:
    Copy code
    Your worker has access to the following bindings:
    - Services:
      - dbg: my-debug-service
    - Vars:
      - foo: "BAR"
    But when I try to access it via
    wrangler dev
    or
    wrangler dev --local
    , I get the following error:
    Copy code
    ReferenceError: dbg is not defined
    Btw, accessing "foo" works. It's only the service binding that's giving me headaches. What am I missing?
  • How can i track how many users are downloading a file?
    n

    nk747

    04/25/2023, 4:54 AM
    Copy code
    js
    addEventListener("fetch", event => {
      event.respondWith(fetchAndStream(event.request))
    });
    
    async function fetchAndStream(request) {
        // Fetch from origin server.
        let response = await fetch("https://speed.hetzner.de/10GB.bin", request);
    
        return new Response(response.body)
    }
    s
    • 2
    • 2
  • Worker usage
    e

    Evernote

    04/25/2023, 11:51 AM
    If the cache API is being used in a worker (like in https://developers.cloudflare.com/workers/examples/cache-api/) and the cache is hit, does it still count towards the workers usage?
    h
    • 2
    • 3
  • Importing Mustache template files directly into a TypeScript-based Worker?
    v

    VirtualWolf

    04/25/2023, 12:12 PM
    Hi everyone! I'm just starting to muck around a bit with Workers and itty-router and Mustache, ultimately what I'm trying to do is to have my Mustache templates as individual files straight in my repository (so I can get nice syntax highlighting in my IDE) and do essentially something like
    import * as template from './templates/template.mustache
    for use with the Mustache library itself. I've come across the workaround of loading the templates from R2 or KV, but I'd like to avoid that if at all possible. Really all I need is just to get them in as a string, I've seen things like this https://stackoverflow.com/questions/46503615/import-html-from-typescript-with-webpack but they're all based on mucking around with Webpack configuration. Given I'm new to all this ideally I'd like to be able to have it working locally with Wrangler2 as well. My understanding is that Wrangler2 uses
    esbuild
    under the covers, is there some customisation I can do with that to make this happen? 🙂 Or something other method that would allow this to work? Any thoughts or insights are greatly appreciated. ❤️
    s
    • 2
    • 15
  • Cloudflare worker as a proxy to AWS S3 HTML file - 403 error
    m

    mbackonja

    04/25/2023, 2:42 PM
    Hello guys, I have issues with the simple Cloudflare worker that acts like a proxy to a single file on a public S3. That worker was working a few months ago and now I need it again, but it doesn't work now... AWS S3 bucket is public, the file is also public, I can access that HTML file directly through the browser (masked bucket name):
    https://xxxxxxx.s3.eu-central-1.amazonaws.com/error.html
    And my worker is like this
    Copy code
    addEventListener('fetch', event => {
      event.respondWith(handleRequest(event.request))
    })
    
    async function handleRequest(request) {
      return await fetch('https://xxxxxxx.s3.eu-central-1.amazonaws.com/error.html')
    }
    And once I attach Cloudflare Worker to some routes, those routes returns
    Copy code
    403 Forbidden
    cloudflare
    but if I open that worked directly through
    xxxxx.workers.dev
    domain it's working as expected (HTML from S3 bucket is returned)...Hello guys, I have issues with the simple Cloudflare worker that acts like a proxy to a single file on a public S3. That worker was working a few months ago and now I need it again, but it doesn't work now... AWS S3 bucket is public, the file is also public, I can access that HTML file directly through the browser (masked bucket name):
    https://xxxxxxx.s3.eu-central-1.amazonaws.com/error.html
    And my worker is like this
    Copy code
    addEventListener('fetch', event => {
      event.respondWith(handleRequest(event.request))
    })
    
    async function handleRequest(request) {
      return await fetch('https://xxxxxxx.s3.eu-central-1.amazonaws.com/error.html')
    }
    And once I attach Cloudflare Worker to some routes, those routes returns
    Copy code
    403 Forbidden
    cloudflare
    but if I open that worked directly through
    xxxxx.workers.dev
    domain it's working as expected (HTML from S3 bucket is returned)... Attached pics: First pic - workers.dev - working Second pic - real domain - not working Third pic - source code of the worker
  • Failed to get worker definitions TypeError: fetch failed
    s

    Subh

    04/25/2023, 3:30 PM
    My local terminal is flooding with this warning, every second. So not able to see the right logs. What is causing this? Is there a way not to see this warnings? I am on node v19.4.0 and ⛅️ wrangler 2.17.0
  • Uploading large file to R2 using worker
    s

    Siclude

    04/25/2023, 5:19 PM
    Hi, I wanted to know if I create a worker that uploads a large file (multiple GBs) to R2 and it takes a long time (lets say above 20 minutes), will the worker time out? I understand that there are reasons to think about multi-part here but I just wanted to know the answer to this independently of multipart considerations. Thanks @Sid | R2 FYI
    k
    • 2
    • 6
  • cloudflare worker requests to another cloudflare worker
    i

    iamc3ll

    04/25/2023, 5:55 PM
    I have a cloudflare worker for my site which is a proxy to another cloudflare worker. They are each configured in a similar way with regard to their routes. When I make a request to the first worker I get a payload of
    Copy code
    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <html><head>
    <title>404 Not Found</title>
    </head><body>
    <h1>Not Found</h1>
    <p>The requested URL /temp-api/ was not found on this server.</p>
    </body></html>
    In development I am unable to produce this error and things work as expected. In the production environment no configuration changes and the routes remain the same. Can anyone point me in the right direction as to why I would be see a 404 for a request to
    /temp-api
    on the same site? The endpoint
    /temp-api
    exists and is functioning correctly for other use cases just not when I make a request from another cloudflare worker.
    v
    • 2
    • 5
  • How to send message to telegram bot api
    r

    RicardoViteri

    04/25/2023, 7:09 PM
    My worker is returning
    {ok: false, error_code: 400, description: 'Bad Request: message text is empty'}
    when I make an API call to Telegram. However, I don't see any problems with my fetch request within my worker. What am I missing in my fetch function?
    Copy code
    js
    const sendMessage = async (message) => {
    
      const token = '--'
      const data = await fetch(`https://api.telegram.org/bot${token}/sendMessage`, {
        method: "POST",
        body: JSON.stringify({
          chat_id: "---",
          text: message
        })
      })
    
      return await data.json()
    }
    k
    • 2
    • 4
  • What is the difference between `CF-Connecting-IP` and `X-Real-IP` and can they ever be empty?
    m

    Mozzy

    04/25/2023, 8:22 PM
    Using it for a simple rate-limiting purpose and was wondering :)
    k
    p
    • 3
    • 7
  • Create a scheduledevent using a timestamp?
    s

    silence

    04/26/2023, 5:03 AM
    I am trying to think of how to make an api endpoint to expire information from my kv store. For example, during the creation of an auth token, I would like to have a piece of code which creates a scheduledevent to execute at a certain epoch; It seems like the only way to do something similar to this is using cron triggers. Is there a way to do it programmatically?
    h
    • 2
    • 2
  • Cannot deploy Nuxt 3 project
    c

    Cactus

    04/26/2023, 1:36 PM
    It builds and uploads the whole project on pages but throws an exception after:
    Success: Assets published!
    The error is something I can't debug:
    Copy code
    Error: Failed to publish your Function. Got error: Uncaught TypeError: Cannot read properties of undefined (reading 'split')
      at functionsWorker-0.08355795516848574.js:5395:32
    Is there a way to know what's going wrong here? For reference: Nuxt 3 + i18n/vue-i18n plugin.
    w
    g
    • 3
    • 10
  • Is it possible to access env variables outside "fetch handler"
    u

    0xAsimetriq

    04/26/2023, 5:25 PM
    Hey everyone. I'm trying to set up few libraries that rely on on environment secrets, but it seems as if these secrets are only available on
    env
    object inside fetch handler? I am using https://hono.dev as a routing library and believe the only way to set up something like supabase client at the moment is via middleware
    Copy code
    app.use('*', async (ctx, next) => {
      const supabase = createClient(ctx.env.SUPABASE_URL, ctx.env.SUPABASE_SERVICE_ROLE_KEY, {
        auth: { autoRefreshToken: false, persistSession: false }
      })
      ctx.set('supabase', supabase)
      await next()
    })
    Is it correct to assume that this is the only way or am I missing something obvious here that allows me to get env variables in global scope as well? Thank you
    h
    • 2
    • 1
  • Workers on Custom Domains
    b

    betim

    04/26/2023, 6:02 PM
    Hello all, looking for clarification on the Workers on Custom Domains scenario documented in the second paragraph of https://developers.cloudflare.com/workers/platform/triggers/custom-domains/#fetch. From the phrasing, I'm taking it to mean that a subrequest fetch to https://api.example.com from worker A hosted on app.example.com (set up as a Cloudflare Custom domain) to worker B hosted on api.example.com (also set up as a Cloudflare Custom domain) should work. Is this correct? From my tests, a fetch from worker A to api.example.com returns an HTTP 522 code. Other possibly pertinent details: - I have other services running on example.com as well as it's other subdomains, all fronted by Cloudflare DNS. - Parent domain name itself was purchased elsewhere but its DNS is hosted on Cloudflare.
  • worker as webhook receiver that sends an SSE message to webclient
    s

    santosmateo

    04/27/2023, 8:54 AM
    Hello, I'm trying is to use a worker as SSE server. Viewing other examples of the SSE implementation, I think they used a setInterval to maintain live the worker and not close the connection. What I'm trying is use the same worker as webhook receiver so fetch data -> send via SSE. For that and communicate the requests to send to the SSE response , I'm use an Rxjs Subject so: 1. request --> send to observer . 2. the subscriber object get the new data from the observer and send the data via SSE. Problem here is that I don't know why the subscribe never is called so the message inside never trigger. Maybe setInterval is blocking? ` export const sseController = () => { const { readable, writable } = new TransformStream(); const headers = new Headers(); headers.append("Content-Type", "text/event-stream"); headers.append("Cache-Control", "no-cache"); headers.append("Connection", "keep-alive"); headers.append("Access-Control-Allow-Origin", "*"); headers.append( "Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept" ); const init = { status: 200, statusText: "ok", headers: headers }; const encoder = new TextEncoder(); const writer = writable.getWriter(); NewLog$.subscribe(async (message: any) => { writer.write(encoder.encode(
    data: ${message}\n\n
    )); }); setInterval(() => { writer.write(encoder.encode(
    data: ${msg}\n\n
    )); }, 5000); return { init, readable }; We call this controller and then construct the response with
    return new Response(readable, init);
    • 1
    • 1
  • Error: process is not defined
    m

    mgency

    04/28/2023, 12:50 AM
    My Worker keeps throwing an error when I run
    wrangler dev
    or
    wrangler publish
    . Here are the steps I took: 1. I created a new worker with wrangelr and added my code to the
    src/index.js
    file. 2. I updated my
    wrangler.toml
    file to this:
    name = "my-project"\n
    main = "src/index.js"
    account_id = "redacted"
    compatibility_date = "2023-04-27"
    3. I installed Webpack and updated my
    webpack.config.js
    file. 4. I ran
    wrangler publish
    and got the following error: ✘ [ERROR] Error on remote worker: ParseError: A request to the Cloudflare API (/accounts/redacted/workers/scripts/my-project/edge-preview) failed. at throwFetchError (/Users/redacted/redacted/_cloudflare-workers/my-project/node_modules/wrangler/wrangler-dist/cli.js:130684:17) at fetchResult (/Users/redacted/redacted/_cloudflare-workers/my-project/node_modules/wrangler/wrangler-dist/cli.js:130651:5) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async createPreviewToken (/Users/redacted/redacted/_cloudflare-workers/my-project/node_modules/wrangler/wrangler-dist/cli.js:132627:29) at async createWorkerPreview (/Users/redacted/redacted/_cloudflare-workers/my-project/node_modules/wrangler/wrangler-dist/cli.js:132648:17) at async start (/Users/redacted/redacted/_cloudflare-workers/my-project/node_modules/wrangler/wrangler-dist/cli.js:151221:34) { text: 'A request to the Cloudflare API (/accounts/redacted/workers/scripts/my-project/edge-preview) failed.', notes: [ { text: 'Uncaught ReferenceError: process is not defined\n' + ' at index.js:2671:11\n' + ' [code: 10021]' } ], location: undefined, kind: 'error', code: 10021 } I'm not really sure what this error means or how to fix this. Anyone know what the problem is?
    k
    • 2
    • 1
  • Unable to perform multi-part upload for files
    i

    Ivan

    04/29/2023, 3:29 PM
    Hi all, I'm currently trying to use a worker to perform a multipart upload of a file on my front-end. Since my website is hosted on vercel, I have no choice but to tunnel my request through their APIs in order to reach my worker. As a result, I have a hard 8mb limit on the size of my function body. However, when I try to perform a multi-part upload, I get the following error
    Copy code
    Error Encountered!
    Error: completeMultipartUpload: Your proposed upload is smaller than the minimum allowed object size.
        at R2MultipartUpload.complete (/Users/ivanleo/Documents/Coding/schulz/tut/node_modules/@miniflare/r2/src/multipart.ts:490:15)
        at Object.fetch (/Users/ivanleo/Documents/Coding/schulz/tut/src/index.ts:99:30)
        at ServiceWorkerGlobalScope.[kDispatchFetch] (/Users/ivanleo/Documents/Coding/schulz/tut/node_modules/@miniflare/core/src/standards/event.ts:385:13)
        at Server.<anonymous> (/Users/ivanleo/Documents/Coding/schulz/tut/node_modules/@miniflare/http-server/src/index.ts:291:20)
    POST /54cbb39f-863d-4365-bc33-d2c31f4a523c.mp4?action=mpu-complete&uploadId=LR5UYQuJToSuQ26G5v_pAYg-bfcsSA_kPKmjbGvhAHy2lqX0n9dFXaUnjZYKI3G-SIdYsBjCTg_3I1srvZqh3GYwK9Oi2GKtxEdhm5jZeV-4kc8hs6c8KaDEHV7Mod32Sa-WiThJoFe1IaWTv0cOF0wwebHBVsOooBky-edIwN8 400 Bad Request (42.35ms)
    It seems to me like the individual upload portions succeed but then when it comes to the final step of completing the multipart upload, I get a 400 error because of the error that
    completeMultiPartUpload
    throws. I'm a bit confused as to how I might be able to fix this. I've tried to modify my partition function so that the last element is always at least 5MB. I originally started slicing from the front (Eg. 12mb file becomes 5 5 2 and the new algorithm would slice it as 2 5 5 ). Any help would be much appreciated. I am using NextJS with typescript and am happy to share source code if needed.
    k
    • 2
    • 13
  • How to use service bindings in Remix?
    t

    Tielem

    04/29/2023, 6:27 PM
    Could anyone give me some guidance on how to use a worker sevice binding locally from within a remix cloudflare pages or (if pages is not possible) worker project? I added the binding to the wrangler.toml like so
    Copy code
    services = [
      { binding = "GATEWAY", service = "gateway-main" }
    ]
    When I locally start the remix project, I see the following output in console
    Copy code
    ▲ [WARNING] This worker is bound to live services: GATEWAY (gateway-main)
    
    
    Your worker has access to the following bindings:
    - Services:
      - GATEWAY: gateway-main
    ▲ [WARNING] ⎔ Support for service bindings in local mode is experimental and may change.
    But I have no idea how to access the binding. The docs make it seem like I can do context.env.GATEWAY or context.GATEWAY in my loader functions - I can't. I also tried looking at the context parameter on server.ts
    Copy code
    export const onRequest = createPagesFunctionHandler({
        build,
        getLoadContext: (context) => {
            console.log(context);
    
            return context.env;
        },
        mode: process.env.NODE_ENV,
    });
    But the context object only has an ASSETS Fetcher on its env parameter.
    Copy code
    {
      ...
      functionPath: '/',
      next: [AsyncFunction: next],
      params: [Object: null prototype] {},
      data: {},
      env: { ASSETS: Fetcher {} },
      waitUntil: [Function: bound waitUntil],
      passThroughOnException: [Function: passThroughOnException]
    }
    I'm a bit very stuck with this and would like advice. Thank you!
    • 1
    • 1
  • Cannot read properties of undefined (reading 'fetch')
    m

    mooon

    04/29/2023, 9:18 PM
    Hey there, I'm using cloudflare workers with
    workers-rs
    and
    wrangler
    . I currently have a basic hello world worker setup:
    Copy code
    rs
    use worker::*;
    
    mod utils;
    
    fn log_request(req: &Request) {
        console_log!(
            "{} - [{}], located at: {:?}, within: {}",
            Date::now().to_string(),
            req.path(),
            req.cf().coordinates().unwrap_or_default(),
            req.cf().region().unwrap_or_else(|| "unknown region".into())
        );
    }
    
    #[event(fetch)]
    pub async fn main(req: Request, env: Env, _ctx: worker::Context) -> Result<Response> {
        log_request(&req);
    
        // Optionally, get more helpful error messages written to the console in the case of a panic.
        utils::set_panic_hook();
    
        // Optionally, use the Router to handle matching endpoints, use ":name" placeholders, or "*name"
        // catch-alls to match on specific patterns. Alternatively, use `Router::with_data(D)` to
        // provide arbitrary data that will be accessible in each route via the `ctx.data()` method.
        let router = Router::new();
    
        // Add as many routes as your Worker needs! Each route will get a `Request` for handling HTTP
        // functionality and a `RouteContext` which you can use to  and get route parameters and
        // Environment bindings like KV Stores, Durable Objects, Secrets, and Variables.
        router
            .get("/", |_, _| Response::ok("Hello from Workers!"))
            .run(req, env)
            .await
    }
    Whenever I attempt to
    GET
    the worker, I receive the following error. Any help would be appreciated
    k
    • 2
    • 7
  • Cache seems to not be storing anything
    c

    Cooleg

    04/29/2023, 10:22 PM
    In my calls TTL is set to 1800 and checking with postman the cache control is being set in my response, so the header is set just fine. I just can't wrap my head around why the console.log is logging undefined for this code that feels like it should be caching properly, but somehow literally just after caching it, its undefined. Any help? Other info: Basically, trying to make a sort of proxy for a online API, but that API has cache headers set to private and 0 cache time, which wasn't allowing the response to be cached. I am creating the new response with all the headers and the body copied but just the Cache-Control modified as I assumed this would work, like the article I linked talks about at the bottom, but the cache is telling me nothing is stored.
    Copy code
    js
    head.set('Cache-Control', 'public, max-age='+ttl+', s-maxage='+ttl);
    let result = new Response(resp.body, {status: 200, headers: head})
    await caches.default.put(req, result.clone());
    console.log(await caches.default.match(req));
    https://developers.cloudflare.com/workers/learning/how-the-cache-works/
    b
    s
    d
    • 4
    • 37
  • Implementation strategies for long-running processes?
    m

    mjswensen

    04/30/2023, 12:33 AM
    At a high level, which combination of Workers features would be the best approach for the following use case? - A long-running process that needs to happen in response to a user action. - The process takes about 1-2 minutes to complete, which is longer than the 30s HTTP request CPU time limit, but it does fit into the 128MB memory limit. I have been reading through the docs and have had some ideas, but I'm not sure if they are optimal or possible: 1. On the user's action, send an HTTP request to a Worker, which creates a Durable Object to handle the long process. Subsequent HTTP requests could poll the Durable Object to check for progress on the task. I'm not sure if there is a way to keep a Durable Object running in the background, outside of an active HTTP request? 2. On the user's action, send an HTTP request to a Worker that inserts a message into a Queue. The queue handler would do the long process work. I'm not sure if the queue handler would be limited to 30s as well, or if it would be subject to the 15-minute limit instead? Am I on track or are there better approaches that I'm not thinking of?
    k
    • 2
    • 8
  • No cache api behind access?
    b

    broswen

    04/30/2023, 4:40 AM
    It looks like cache api doesn't work if Cloudflare Access is running in front of a worker?
    For Workers fronted by Cloudflare Access, the Cache API is not currently available.
    What are the other options for using a cache if I need my worker to be protected via Access Service Tokens? Is it recommended roll my own simple token auth system using KV?
  • Transferring a domain to another website
    i

    Its_Honzaa

    04/30/2023, 3:13 PM
    Hi, I already own a .net domain at "testweb.net" and would like to convert it to "bestweb.net"... Is there any way to do this? Thank you in advance... :)
    h
    c
    w
    • 4
    • 13
  • Get total consumed bandwidth while streaming response to user using workers.
    s

    Stavros

    04/30/2023, 4:08 PM
    I'm using a worker to proxy data from an origin server of mine. I would like to know how many bytes have been streamed from the worker that is proxying my origin server. Any thoughts on how to find the total consumed egress bytes while streaming the response?
    z
    • 2
    • 1
  • We have a domain registered with Namecheap, but we're usind Cloudflare for DNS. The nameservers etc
    d

    DarkLordDLDL

    04/30/2023, 8:00 PM
    We have a domain registered with Namecheap, but we're usind Cloudflare for DNS. The nameservers etc is all setup properly and working, no problems there. Before we moved the DNS to Cloudflare we had a sub-domain that pointet to a invitation link for our Discord server. This invite has recently stopped working and I have to replace it with a new invite link. This is where the problems are starting, because the current sub-domain is a A record pointing to an IP, while on Namecheap, this record was a CNAME pointing directly to the invite link. I have now deleted that from the DNS on Cloudflare. So, how do I create a new sub-domain that points directly to a Discord invite link? (I did try to figure it out online before I came here in search for answers.)
    z
    c
    • 3
    • 15
  • Local R2 Bucket Error
    d

    dkfdkdodkms

    05/01/2023, 8:07 PM
    I am trying to use a local R2 bucket for localhost development. But this toml entry: [[r2_buckets]] binding = 'testBucket' bucket_name = 'testBucket' is giving me this error message: X [ERROR] In development, you should use a separate r2 bucket than the one you'd use in production. Please create a new r2 bucket with "wrangler r2 bucket create " and add its name as preview_bucket_name to the r2_buckets "testBucket" in your wrangler.toml
    j
    • 2
    • 4
  • how to use packages from 'works on workers'
    i

    ItzDragon

    05/02/2023, 7:26 AM
    I want to use a module from this page https://workers.cloudflare.com/works in my worker, how do I do ?
    z
    • 2
    • 6
  • Wrangler publish works in terminal but fails in GH action
    s

    Successor1

    05/02/2023, 12:10 PM
    When I run
    wrangler publish
    in terminal, the app successfully deploys but when I try to do it through github worker, it doesn't. This broke after I've installed toucan.js to get some sentry monitoring in my worker. The failing step in
    .github/workflows/main.yml
    is :
    Copy code
    deploy:
        needs: run-tests
        runs-on: ubuntu-latest
        name: Deploy
        steps:
          - uses: actions/checkout@v2
          - name: Publish
            uses: cloudflare/wrangler-action@2.0.0
            with:
              apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
    The error it throws is:
    Copy code
    ✘ [ERROR] Could not resolve "toucan-js"
    
        src/index.ts:53:23:
          53 │ import { Toucan } from 'toucan-js';
             ╵                        ~~~~~~~~~~~
    
      You can mark the path "toucan-js" as external to exclude it from the bundle, which will remove this error.
    Before that I didn't have any external dependency and my package.json is:
    Copy code
    {
      "name": "name",
      "version": "0.0.0",
      "devDependencies": {
        "@cloudflare/workers-types": "^3.18.0",
        "@jest/globals": "^29.5.0",
        "@types/jest": "^29.2.2",
        "@types/node": "^18.11.9",
        "@typescript-eslint/eslint-plugin": "^5.59.2",
        "@typescript-eslint/parser": "^5.59.2",
        "eslint": "^8.39.0",
        "ts-jest": "^29.1.0",
        "typescript": "^4.8.4",
        "wrangler": "^2.18.0"
      },
      "private": true,
      "scripts": {
        "dev": "wrangler dev",
        "deploy": "wrangler publish",
        "test": "jest",
        "lint": "eslint . --ext .ts"
      },
      "dependencies": {
        "toucan-js": "^3.1.0"
      }
    }
    Any idea what am I doing wrong? How can I mark
    toucan-js
    as external?
    k
    • 2
    • 9
  • worker processing traffic but not injecting code
    r

    Rahner

    05/02/2023, 3:46 PM
    I am trying to use a worker to intercept a website request, and inject javascript into the html header on a server response. I am effectively using the worker injection code from https://stackoverflow.com/questions/56660355/how-to-inject-javascript-in-existing-html-response-with-node-js-and-cloudflare-w When I test the website in the worker development tool, the interception and injection works fantastically, but when I go to the website using my browser, there is a complete absence of evidence of my injected code. I checked the dns settings and cloudflare is showing the traffic is proxied, I added routes for the domains in question, and the worker is showing requests in the summary dashboard with minimal errors, but I cannot figure out why the worker wouldnt be injecting the code properly. Is there anything I can do to find out why the code isnt being injected into the responses?
    z
    j
    • 3
    • 3
  • A low-latency solution for external authorization?
    n

    navaru

    05/02/2023, 6:06 PM
    What is a low-latency solution to use a system like OpenFGA / SpiceDB for authorization in workers? On what platform I can host OpenFGA, for example, and have low latency between workers and OpenFGA?
12345...10Latest