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

    Quacksire

    01/07/2023, 12:51 AM
    My project isn't huge, just Nextjs, NextUI, and swr essentially
  • q

    Quacksire

    01/07/2023, 12:51 AM
    I'll move things to a worker and see if that does it
  • j

    James

    01/07/2023, 12:51 AM
    You're probably hitting https://github.com/cloudflare/next-on-pages/issues/47
  • j

    James

    01/07/2023, 12:53 AM
    If I were you with a Next project, I would seriously consider moving to Netlify or Vercel. Their support for Next.js is much further developed and supported unfortunately. I've seen too many people waste hours of their time ๐Ÿ˜…
  • q

    Quacksire

    01/07/2023, 12:53 AM
    got it
  • j

    James

    01/07/2023, 12:54 AM
    If you do continue, I'd definitely encourage you to file any issues on that repo. I just can't really give you any kind of ETA for stuff getting fixed ๐Ÿ˜…
  • q

    Quacksire

    01/07/2023, 12:54 AM
    thanks for the help anyway!
  • g

    gunnars04

    01/07/2023, 11:35 AM
    hi guys, been thinking of a page rule caching strategy for a potentially high traffic SPA. Option 1: (as described here in "Best Practice 2"): https://support.cloudflare.com/hc/en-us/articles/360021023712: 1. Cache Everything (to act as catch all for static, anonymous content) 2. Bypass Cache on Cookie (to bypass caching everything if the request has a matching cookie) -> in my case an auth cookie 3. Origin Cache Control (to specify how long Cloudflare should keep the cached resource in our edge network before asking the origin for it again) -> I would call a REST endpoint in Azure which would return a reponse with a header telling CF how long to cache. My data would be in Azure. Regarding nr. 2, since Pages Functions run in front of cache, I was thinking of implementing the protected (auth cookie required) endpoints with Functions (calling the Azure origin, in Functions I could use fine grained cache control there, meaning cache/invalidate cache responses there for logged-in user x) Option 2: Do everything in CF and use Pages Functions, R2, Cache, etc. I'm leaning towards option 2 atm for perfomance/price (particularly egress) reasons. Do you agree?
  • f

    fluidsonic

    01/07/2023, 3:37 PM
    Is there any documentation on how to install and use npm packages in functions in Cloudflare Pages? There seems to be no documentation on that. How does the
    package.json
    has to look like? What directory does it go to? The errors when deploying are not helpful at all ๐Ÿ˜ฆ
    You can mark the path "@tsndr/cloudflare-worker-jwt" as external to exclude it from the bundle, which will remove this error
  • j

    James

    01/07/2023, 3:42 PM
    Copy code
    package.json
    dist
      index.html
    functions
      hello-world.js
    I don't think there's any specific documentation, but you'd probably want the
    package.json
    in your root with a structure like that. Then it should just be as simple as `import`ing them. If you're having trouble, a git repo or something to reproduce the problem would be great ๐Ÿ™‚
  • m

    Marcelino Franchini

    01/07/2023, 3:49 PM
    Pages Functions bypass the Cache Reserve, is there any way to put a Function response behind the Argo Tiered Cache without using a double proxy like Bunny Origin Shield?
  • w

    Walshy | Pages

    01/07/2023, 3:53 PM
    Workers run before cache
  • w

    Walshy | Pages

    01/07/2023, 3:53 PM
    That cannot be changed
  • m

    Marcelino Franchini

    01/07/2023, 4:02 PM
    Is there any workaround other than use a double proxy? Maybe a CNAME chain to trick the reverse proxy to treat the Pages origin as external traffic and use the tiered caching?
  • f

    fluidsonic

    01/07/2023, 4:03 PM
    Thank you. Unfortunately, that doesn't work either. Still getting "You can mark the path "@tsndr/cloudflare-worker-jwt" as external to exclude it from the bundle, which will remove this error.". It looks like the automatic Cloudflare Pages deployment isn't running
    npm install
    . How can that be triggered automatically?
  • j

    James

    01/07/2023, 4:04 PM
    If you have a
    package.json
    in the root, Pages CI will run
    npm install
    automatically.
  • j

    James

    01/07/2023, 4:04 PM
    Can you share a repo or something to reproduce this?
  • w

    Walshy | Pages

    01/07/2023, 4:06 PM
    do you have a build command set?
  • f

    fluidsonic

    01/07/2023, 4:06 PM
    omg I've set that up way too much time ago and forgot that there are these settings per Page. Setting
    build command
    to
    npm install
    fixes it.
  • w

    Walshy | Pages

    01/07/2023, 4:06 PM
    yeah...
  • w

    Walshy | Pages

    01/07/2023, 4:06 PM
    we really need to do something about that
  • w

    Walshy | Pages

    01/07/2023, 4:06 PM
    i'd just use
    exit 0
    for now
  • j

    James

    01/07/2023, 4:07 PM
    Yeah having to set it to something to trigger expected behaviour isn't very ergonomic
  • f

    fluidsonic

    01/07/2023, 4:08 PM
    A good example project and step-by-step documentation for functions that use packages would be helpful. Anyway, got it solved now. Thanks for the emotional support ๐Ÿ˜„
  • x

    Xan

    01/07/2023, 8:28 PM
    Hey! Is it possible to install npm packages in pages functions, and if so, is there a guide to look at somewhere?
  • j

    James

    01/07/2023, 8:40 PM
    Yep! We discussed this a bit just earlier today. It should "just work" ๐Ÿ™‚ https://discord.com/channels/595317990191398933/910978223968518144/1061308850390708284
  • b

    bkyerv

    01/08/2023, 9:08 AM
    Is there any flags or other configurations that need to be set in order to use env variables in local development? I have set up env variables in the dashboard and they are available in the prod but when developing locally I am stuggling with an error
    Copy code
    [pages:err] Cause: Error: getaddrinfo ENOTFOUND undefined
  • e

    Erisa | Support Engineer

    01/08/2023, 2:43 PM
    local env variables need to be in a
    .dev.vars
    file in the .env format like
    myvar=myvalue
  • m

    mpeg

    01/09/2023, 12:21 AM
    is there any plan to make pages functions support creating durable objects? currently you have to run a separate worker to expose the DO, and there doesn't seem to be a way around that.
  • w

    Walshy | Pages

    01/09/2023, 12:28 AM
    Durable objects are quite special in the way of creating and deploying them.
1...327328329...392Latest