https://discord.cloudflare.com logo
Join Discord
Powered by
# functions
  • a

    AoElite

    01/13/2022, 2:46 AM
    yea looks great cole, nice domain too
  • e

    Epailes

    01/13/2022, 11:33 AM
    This is cool! If my understanding is right, you're creating a single image from merging all the underlying images? How long does this take to execute?
  • w

    Walshy | Pages

    01/13/2022, 11:40 AM
    HOLY, that's insane
  • g

    Greg Brimble | Cloudflare Pages

    01/13/2022, 1:17 PM
    You can't reply with that to me and hour and a half after my message!!
  • w

    Walshy | Pages

    01/13/2022, 1:19 PM
    Still should have been asleep at the time of your message!
  • e

    Erwin

    01/13/2022, 1:30 PM
    What @Walshy | Pages said..
  • j

    Josh

    01/13/2022, 1:32 PM
    https://sleep.workers.community/erwin
  • j

    Josh

    01/13/2022, 1:32 PM
  • r

    reitznerdomenik

    01/13/2022, 2:49 PM
    Hi, short question about debugging api calls.... I build a svelte-kit app with the cloudflare adapter (which boils down to a _worker.js file) Inside one of my api endpoints I call the dev.to api. I tested my build locally with
    npx wrangler@beta pages dev .
    and it works perfectly. As soon as I deploy I get a 403 error (I already checked the auth header, that I need to set) I log the output here as the last entry https://reitzner-at.pages.dev/blog.json Is there a way to debug, why it is failing?
  • t

    travtrax

    01/13/2022, 3:35 PM
    Hey all. I created an extremely simple form html page that uses fetch to post to a /function. That function receives the request but I simply echo back what it receives. I echo the entire context. And it always returns what I would expect in the context except for any data posted. I've confirmed in the browser that the network data shows data being sent. And I've used a direct curl post from my terminal and the same thing. A full context but the body of the request is always empty and the usedBody is always false. I've tried every combination of content-type and formData vs json vs string. What am I doing wrong, or how do I possibly troubleshoot this?
  • b

    bsam75

    01/13/2022, 3:40 PM
    I do have it in my static asset directory. I have it at the root of the project when I run
    npx wrangler pages dev ./
    still does not pick it up. Im using wrangler 0.0.7
  • b

    bsam75

    01/13/2022, 3:47 PM
    Actually, it seems to work if I remove my functions directory
  • g

    Greg Brimble | Cloudflare Pages

    01/13/2022, 4:01 PM
    Ah yes, I think we are prioritizing
    functions
    folder over a
    _worker.js
    script. Maybe that should be the other way around?
  • b

    bsam75

    01/13/2022, 4:02 PM
    Yea, the docs are stating that _worker.js will ignore the functions directory
  • g

    Greg Brimble | Cloudflare Pages

    01/13/2022, 4:02 PM
    Where abouts does it say that?
  • g

    Greg Brimble | Cloudflare Pages

    01/13/2022, 4:03 PM
    We’ll make sure wrangler & docs & production are all synced up for GA
  • b

    bsam75

    01/13/2022, 4:03 PM
    Unless Im interpreting it wrong it says here: https://developers.cloudflare.com/pages/platform/functions#advanced-mode
    When using a _worker.js file, the entire /functions directory is ignored – this includes its routing and middleware characteristics. Instead, the _worker.js file is deployed as is and must be written using the Module Worker syntax.
  • g

    Greg Brimble | Cloudflare Pages

    01/13/2022, 4:04 PM
    Cool. I’ll look into it. Thanks!
  • b

    bsam75

    01/13/2022, 4:04 PM
    your welcome thanks for looking into it
  • t

    travtrax

    01/13/2022, 5:51 PM
    Fixed it. For anyone just trying functions, you need to wait for the request body. I'll post a template starter later.
  • c

    Cоlе

    01/13/2022, 6:09 PM
    The picture I sent above seems to take <300ms to run, but I haven't actually timed it. It seems to go pretty fast, but I'm sure you'd run into a little trouble if you used bigger images
  • c

    Cоlе

    01/13/2022, 6:10 PM
    It's definitely not the most efficient, but it's the only way I could find lol
  • c

    Cоlе

    01/13/2022, 6:12 PM
    If someone had a way to read the image dimensions from the base64, I'm sure someone could make an ultra lightweight library out of it
  • c

    Cоlе

    01/13/2022, 6:13 PM
    Altho opacity, blending, resizing, sampling would all need to be coded from zero
  • b

    bsam75

    01/13/2022, 7:45 PM
    Is there a way to have a
    /functions/[[slug]].js
    worker that theoretically runs on everything but have it only run the worker if the path doesnt already exist in the pages project?
  • g

    Greg Brimble | Cloudflare Pages

    01/13/2022, 7:48 PM
    No. Functions will always execute before static assets.
  • c

    Cоlе

    01/13/2022, 7:49 PM
    if I understand what you're saying, you could achieve that through middleware
  • c

    Cоlе

    01/13/2022, 7:49 PM
    1s
  • b

    bsam75

    01/13/2022, 7:49 PM
    Thanks Cole I had not looked into that yet
  • c

    Cоlе

    01/13/2022, 7:50 PM
    I'll pull up an example
1...585960...392Latest