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

    orstavik77

    04/22/2022, 8:26 AM
    Do I need to do something like
    npx wrangler <download copy of KV=TEST_DB to my local machine so I can test it>
    command first?
  • o

    orstavik77

    04/22/2022, 8:33 AM
    Also. And this is a suggestion. What if the wrangler build script that compiles and sets up the worker, printed out its full command? This would be really nice and useful to see. Or. Even better. If it printed out the complete command for testing locally with the same settings for KV and DO and VARS? This would be a one stop shop for lots of slightly more advanced documentation needs.
  • o

    orstavik77

    04/22/2022, 8:41 AM
    I tried to rename the functions variable to also be
    TEST
    so that there would be no difference between the two. Still
    null
    locally. When I
    console.log(env.TEST)
    locally, i get
    KVNameSpace {}
    . It works fine up on the server.
  • s

    Skye

    04/22/2022, 8:42 AM
    As I said, there is no syncing between local and production
  • o

    orstavik77

    04/22/2022, 8:43 AM
    ok. and then i need to make a local copy and then fill it with some test data?
  • s

    Skye

    04/22/2022, 8:44 AM
    When you put
    --kv TEST
    in your command (or whatever you call your namespace), it creates a local version in your filesystem which has no initial data
  • s

    Skye

    04/22/2022, 8:44 AM
    I believe it only actually shows up after you store something in it though
  • o

    orstavik77

    04/22/2022, 9:19 AM
    thanks) I finally have something! Hehehe😅 My first instinct (mayor exaggeration;) was to run
    npx wrangler kv:namespace
    and then
    kv:put
    commands. Which worked after a little while. Worked on the server that is (which i don't need). But not locally (which i do need). Ok. Delete that. Move on. Second attempt was.. should I make a custom worker that will fill the table with some startup data? And that worked. That created the
    .mf>kv>TEST
    folder with "hello" file with the content "world". and a "hello.meta.json" too, just to test. So. My final question is. To create a local KV store for local test purposes, should I just create these files manually? So that I have something to read?
  • o

    orstavik77

    04/22/2022, 9:21 AM
    So thanks for the tip with the local version of the KV, @Skye😀
  • s

    Skye

    04/22/2022, 9:21 AM
    If you're just using a small amount of data, you may as well just manually create the files, yes
  • s

    Skye

    04/22/2022, 9:21 AM
    If you need a bit more, it may be useful to setup a route that fills it for you? (you could get this to 404 or whatever in production)
  • a

    amancoder28

    04/25/2022, 4:56 AM
    Is Pages functions Workers Request count separated from the main Workers Request count? Or they will be merged at the end?
  • p

    patrickheneise

    04/25/2022, 9:03 AM
    Is there a solution / workaround to the CORS issues on Cloudflare Functions? I'm trying
    Copy code
    const req = await fetch('https://api.sendgrid.com/v3/mail/send', {
          method: 'POST', ...
    which fails with a CORS error 😦
  • k

    kian

    04/25/2022, 9:08 AM
    You can make a CORS proxy in a Worker - https://developers.cloudflare.com/workers/examples/cors-header-proxy/
  • k

    kian

    04/25/2022, 9:08 AM
    Probably adapt that for Functions too if you wanted
  • p

    patrickheneise

    04/25/2022, 9:13 AM
    so I need a worker to proxy a function to send an email?
  • i

    Isaac McFadyen | YYZ01

    04/25/2022, 1:08 PM
    Functions are in beta right now, so that 100k limit is maximum (seperate from Workers). You can't pay more to get more Functions requests but you can request a quota increase here: https://docs.google.com/forms/d/e/1FAIpQLSe4N0BjIxu9AuissCAtYjXUovViXmdx2zopjzASaJi_SImJsw/viewform?usp=send_form
  • i

    Isaac McFadyen | YYZ01

    04/25/2022, 1:09 PM
    Once Functions hit GA, then they will be billed similar to Workers.
  • o

    orstavik77

    04/25/2022, 1:45 PM
    Is there any estimate when compatibility_date will be added to pages/functions? 🙂
  • o

    orstavik77

    04/25/2022, 1:59 PM
    I don't know how you would best do it, but 1. in pages/settings/functions: a "compatibility_date": <input type=text pattern="\d{4}-\d\d{1,2}-\d{1,2}" 2. wrangler pages dev --compatibility_date="2021-12-24" would fit the rest of the api in my mind. If it is weeks away, I would probably need to implement some shortlived bypass... That feels sad... If it is days away, that would be like christmas:) Hours you said??! No, no, that would be too good to be true!! 😄
  • j

    James

    04/25/2022, 2:25 PM
  • u

    ! ThaUnknown_

    04/25/2022, 10:37 PM
    oops, mistake with KV
  • j

    James

    04/25/2022, 10:39 PM
    I was replying to your message and it disappeared before my eyes
  • a

    Angius

    04/25/2022, 11:22 PM
    Do functions not support secrets? All I see are plaintext env variables
  • j

    James

    04/25/2022, 11:23 PM
    No secret support today unfortunately, but I know it's on the todo list
  • a

    Angius

    04/25/2022, 11:23 PM
    That's a bummer, but oh well
  • a

    Angius

    04/25/2022, 11:24 PM
    Thanks for the answer!
  • u

    ! ThaUnknown_

    04/25/2022, 11:29 PM
    cant u use KV for it in theory?
  • u

    ! ThaUnknown_

    04/25/2022, 11:29 PM
    not the most secure thing ever, but secure enough
  • u

    ! ThaUnknown_

    04/25/2022, 11:30 PM
    was just dumb, wrong var name, always the coders fault
1...126127128...392Latest