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

    Zottelchen🍭

    03/26/2022, 11:30 PM
    I am struggling with a function. When running it locally it works, when deployed I get Error 1101 ...
  • z

    Zottelchen🍭

    03/27/2022, 12:13 AM
    Seem to have found the issue:
    Copy code
    await env.<KV>.put('authToken', String(acc_auth["authorizationToken"]), {expirationTtl: 79200});
    does not seem to work. What am I doing wrong?
  • q

    qard

    03/28/2022, 2:19 AM
    Think I just ran into the no-polyfills issue. Tried using
    apollo-server-cloudflare
    in a function to back a pages app, but it falls over with "could not resolve" errors for a bunch of Node.js core modules. 😢
  • c

    cvejic092

    03/28/2022, 12:00 PM
    Is there a way with functions to implement ab test? So i want when i hit / to display homepage-1 50% and homepage-2 50% but i don't want url to be changed
  • w

    Walshy | Pages

    03/28/2022, 12:36 PM
    Yes, here is a very quick example
    Copy code
    js
    // functions/index.js
    export async function onRequestGet({ env }) {
      if (Math.floor(Math.random() * 50) < 50) {
        return env.ASSETS.fetch('/index');
      } else {
        return env.ASSETS.fetch('/new-index');
      }
    }
  • c

    cvejic092

    03/28/2022, 12:40 PM
    I've already tried that but i'm getting
    Failed to parse URL from /homepage-2
    and I have in my output directory homepage-2/index.html. It somehow started working, but i'm still getting /homepage-2 url and i don't want that, i want root path to stay unchanged.
  • i

    Isaac McFadyen | YYZ01

    03/28/2022, 12:49 PM
    Make sure the method lines up with what you want.
  • i

    Isaac McFadyen | YYZ01

    03/28/2022, 12:49 PM
    The one Walshy sent there is POST which I'm not sure whether you want or not.
  • w

    Walshy | Pages

    03/28/2022, 12:49 PM
    you can tell I quickly copied that haha
  • c

    cvejic092

    03/28/2022, 12:49 PM
    I'm already using get
  • w

    Walshy | Pages

    03/28/2022, 12:50 PM
    Try doing
    /homepage-2/
  • c

    cvejic092

    03/28/2022, 12:50 PM
    Nope, same, still getting url rewrite.
  • t

    tmw

    03/28/2022, 6:51 PM
    Can someone from cloudflare help me urgently? Just launched our website with cloudflare pages and functions and hit the usage limit
  • t

    tmw

    03/28/2022, 6:51 PM
    @User maybe? 🙂
  • t

    tmw

    03/28/2022, 7:28 PM
    Anyone from the cloudflare team?
  • h

    hakan_

    03/28/2022, 7:59 PM
    upgrade?
  • i

    Isaac McFadyen | YYZ01

    03/28/2022, 7:59 PM
    Functions aren't included in the Pages quota, you can't pay for more yet.
  • i

    Isaac McFadyen | YYZ01

    03/28/2022, 7:59 PM
    The increase is on a request-only basis right now.
  • h

    hakan_

    03/28/2022, 7:59 PM
    ah okay
  • t

    tmw

    03/28/2022, 8:06 PM
    Yeah I'm trying to request more but can't really wait for a response on the form
  • t

    tmw

    03/28/2022, 8:06 PM
    was hoping I could fast track it somehow
  • w

    Walshy | Pages

    03/28/2022, 8:20 PM
    Request more on the form and send me your account ID
  • t

    tmw

    03/28/2022, 8:25 PM
    done! account id is 2e41a85cca723a60eb3565b9c448e4c3 ty 🙏
  • b

    Bytesource

    03/29/2022, 1:17 AM
    Well, I have to admit, I made a stupid mistake, which let me believe, importing
    .ts
    files wasn't supported on Cloudflare Pages. In fact, there's no problem with the Typescript support, and it works as well on localhost (using
    npx wrangler pages dev
    ) as it does on the server. So, what was the issue then? As it turns out, I had added the single
    .ts
    file I used for testing to
    .gitignore
    , so the file didn't ever get to the server. No wonder, Cloudflare Pages couldn't import it 😖
  • m

    MAXOUXAX

    03/29/2022, 7:36 AM
    Is there any way to see error logs of Cloudflare Pages Functions in production?
  • i

    Isaac McFadyen | YYZ01

    03/29/2022, 12:18 PM
    Unfortunately not yet, it's a planned feature for once Functions gets out of beta.
  • i

    Isaac McFadyen | YYZ01

    03/29/2022, 12:18 PM
    (Pages are not beta, but Functions are at the moment)
  • f

    furf

    03/29/2022, 9:17 PM
    did you ever solve this issue? i'm seeing errors when i try to require 'launchdarkly-cloudflare-edge-sdk' in my worker (TS, esbuild)
  • r

    remotesynth

    03/29/2022, 9:23 PM
    Not with the Pages integration using the Wrangler 2 beta as it doesn't provide a means of adding a Webpack config and my understanding is there are no plans to do so. There were some updates we could make on our end to make this work without Webpack and afaik it's on our todo list but there hasn't been a ton of demand so it's been lower priority. I'd suggest maybe adding an issue here https://github.com/launchdarkly/node-server-sdk but feel free to reach out and I can see what I can do internally.
  • m

    markoan

    03/30/2022, 3:32 AM
    how do you set secrets to be used by functions? should I just add them as environment variables? can they be protected as secrets like they can in a worker configuration?
1...109110111...392Latest