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

    advaith

    04/07/2023, 7:38 PM
    but i get a warning abt cloudflared when running a normal apt update anyway lol
    c
    • 2
    • 8
  • a

    advaith

    04/07/2023, 7:38 PM
  • m

    msutkowski

    04/07/2023, 10:15 PM
    is anyone aware of a documented workers limitation when using custom subdomains that causes 503 origin errors? for example: - subdomain.example.com is in CF DNS, but as NS records that point to google dns, that has an A record pointing to a load balancer - someworker.example.com is a CF Worker. when someworker makes a request to subdomain.example.com from a custom subdomain, this will 503. if you access the workers.dev route for the worker, it will work. in this same exact scenario, if the subdomain.example.com was set to a wildcard in google dns and you accessed nested.subdomain.example.com, this will resolve. is this documented anywhere or any other suggested workaround (other than changing to an A record)? 😓
  • c

    chientrm

    04/08/2023, 3:16 AM
    At my external service with database, I have table
    Student(id, name)
    . User can change student info. Is it a good idea to add an extra field
    Student(id, seed, name)
    where
    seed
    changes every time
    name
    changes. Then in my worker, I can do:
    Copy code
    ts
    fetch(`${API}/student/${id}/seed/${seed}`, { cf : { cacheEverything: true } })
    So that I can cache student record indefinitely without worrying about stale data 🤔
  • c

    chientrm

    04/08/2023, 3:19 AM
    Oh. I can just use the
    updatedAt
    instead of
    seed
    .
  • c

    chientrm

    04/08/2023, 3:22 AM
    Please let me know your thoughts 👍
  • x

    xHyroM

    04/08/2023, 9:16 AM
    hey im getting but i have nodejs_compat flag
    Copy code
    bot:dev: [mf:err] VMScriptRunnerError [ERR_MODULE_RULE]: Unable to resolve "dist\worker.mjs" dependency "node:events": no matching module rules.
    bot:dev: If you're trying to import an npm package, you'll need to bundle your Worker first.
    also I need a little advice. I'm making a serverless discord bot, and I have a /setup command that sends a message with a select menu. In discord.js I could then use
    interaction.awaitMessageComponentInteraction
    but in this case I can't. I was thinking of making my own such function that would listen for an EventEmitter that would be global, but I'm not sure if that's the best solution. Because I want to have everything in one function, and I don't want to separate it in any way. If you have any ideas, I'd certainly be happy to.
  • d

    drathier

    04/08/2023, 9:21 AM
    Can I use workers as the only backend of my app? I don't need much data storage, so it seems like it should be fine, but I'm having trouble figuring out what parts (if any) are actually persistent, and what parts are deleted when no longer in use. For example,
    durable objects
    sounds very persistent to me, but apparently they get thrown away if not in use?
  • c

    chientrm

    04/08/2023, 9:21 AM
    possible.
  • c

    chientrm

    04/08/2023, 9:22 AM
    it depends on what tech do you need in your backend.
  • h

    HardAtWork

    04/08/2023, 9:25 AM
    The response would be in a complete different request, so you would have to handle it separately
  • d

    drathier

    04/08/2023, 9:43 AM
    I need to store small json objects. No computation other than access rights.
  • h

    HardAtWork

    04/08/2023, 9:44 AM
    If they are small enough, you can just inline them directly into your Worker
  • c

    chientrm

    04/08/2023, 9:44 AM
    as long as no hanging connections that require pre-processing or post-processing by worker 👍
  • d

    drathier

    04/08/2023, 9:46 AM
    Sorry, I don't understand either of your responses. I want a "server" that can expose a rest api or websocket, and read/write json objects. What's pre/post processing here? And inlined json objects would be static, no?
  • h

    HardAtWork

    04/08/2023, 9:47 AM
    Oh you want dynamic. The REST API can be a Worker with a router. WebSockets are best handled in a Durable Object. JSON objects that don’t change very often can be stored in KV
  • c

    chientrm

    04/08/2023, 9:47 AM
    I was unclear. I mean, as long as it fit worker limits 🐸
  • d

    drathier

    04/08/2023, 9:49 AM
    "that don’t change very often" how often is very often? Should I use something else for this storage?
  • h

    HardAtWork

    04/08/2023, 9:50 AM
    If you need it to update multiple times per minute, then it might not be the best choice
  • d

    drathier

    04/08/2023, 9:50 AM
    I feel super novice here. Are people using workers for anything other than caching in front of an existing backend, hosted outside of cloudflare?
  • h

    HardAtWork

    04/08/2023, 9:51 AM
    Yes. You can host entire websites on them. You can use them for security, form validation, logging, caching, interactions with databases, and many more applications
  • d

    drathier

    04/08/2023, 9:53 AM
    Cool. I couldn't find an example showing a super simple data storage api hosted only on cloudflare. I looked through all the examples at https://developers.cloudflare.com/workers/examples/ Am I missing something obvious?
  • x

    xHyroM

    04/08/2023, 9:57 AM
    I have small image uploader using CF workers
  • x

    xHyroM

    04/08/2023, 9:58 AM
    But it's not probably what you want
  • d

    drathier

    04/08/2023, 9:59 AM
    it sounds fairly close to what I want
  • d

    drathier

    04/08/2023, 9:59 AM
    if I can also upload json somewhere, it'd be what I want 🙂
  • d

    Deleted Account

    04/08/2023, 11:04 AM
    is there any other way to make the response faster and not too laggy?
    Copy code
    export default {
      fetch(req) {
        const url = new URL(req.url);
        url.hostname = 'exampledomain.com';
    
        return fetch(url, req)
      }
    };
  • s

    Skye

    04/08/2023, 11:05 AM
    The only 'slow' part of that is waiting for the origin
  • s

    Skye

    04/08/2023, 11:05 AM
    Whatever domain you're actually fetching, so if you can make that faster, your worker will be faster
  • d

    Deleted Account

    04/08/2023, 11:06 AM
    so the worker is depending on the domain?
1...238223832384...2509Latest