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

    CandyViz

    12/29/2022, 8:10 PM
    Is there a timeline for when it may be made available?
  • w

    Walshy | Pages

    12/29/2022, 8:14 PM
    There is not, there's complexity involved because the Functions map to your pages.dev not your custom domain. Your pages.dev zone doesn't have image resizing
  • c

    CandyViz

    12/30/2022, 12:21 AM
    ok thanks for the info. I will stick with using plain workers for just the image portion. Was hoping I could align all my code in one deploy flow using pages/functions
  • j

    JustinNoel

    12/30/2022, 2:29 PM
    Here's what I did: 1) Store my images in R2 2) Make my R2 bucket public but never expose the public URL 3) Have a Functions route for the images :
    mydomain.com/profile-photos/ABC123.jpg?width=1024,quality=75
    etc 4) In my function for that route, I proxy the request to the public R2 domain to something like:
    mydomain.com/cdn-cgi/image/width=1024,quality=75/https://pub-MY_PUBLIC_R2_DOMAIN_HERE.r2.dev/ABC123.jpg
    It works great and I get a response:
    cf-resized: internal=ok/- q=0 n=280 c=15+87 v=2022.12.7 l=79202
  • e

    Epailes

    12/30/2022, 2:34 PM
    Have you done any analysis on whether you'd save money by also storing the resized images in R2 instead of resizing them on demand?
  • j

    JustinNoel

    12/30/2022, 2:35 PM
    No, Right now, I'm not expecting enough traffic to even exceed the free limits
  • e

    Epailes

    12/30/2022, 2:36 PM
    Out of curiosity, is this also the reason for complexities around other features like wildcard custom domains not being supported for pages?
  • w

    Walshy | Pages

    12/30/2022, 2:39 PM
    Pretty much yep. SSL for SaaS Enterprise is needed for wildcards. The pages.dev zone is the these are added (obviously), that doesn't have SSL for SaaS ENT.
  • w

    Walshy | Pages

    12/30/2022, 2:41 PM
    It's on the roadmap to support it regardless. We just need to work with the ssl for SaaS team
  • c

    CandyViz

    12/30/2022, 5:46 PM
    Justin that is a very interesting approach. I am trying to determine if it works for my use case. I don't know that is will since I am using some image features that are only available in workers. I am actually layering in 7 different images together to stitch them together with cf images using the
    options.cf.image.draw.push({});
    option. Like I said I have it working in plain workers at the moment but would love to use functions from a code stand point so I can have it all live with my other functions and deploy it all in the same way.
  • a

    akshay

    12/30/2022, 9:15 PM
    I'm trying to deploy as instructed here and get this error on deployment, is something broken? https://github.com/cloudflare/next-on-pages
    Copy code
    12:50:36.162    Verify run directory
    12:50:36.162    Executing user command: npx @cloudflare/next-on-pages
    12:50:36.330    /opt/buildhome/repo/node_modules/@cloudflare/next-on-pages/dist/index.js:6013
    12:50:36.330                  ({ type, expression }) => type === "ExpressionStatement" && expression?.type === "CallExpression" && expression.callee?.type === "MemberExpression" && expression.callee.object?.type === "AssignmentExpression" && expression.callee.object.left?.object?.name === "self" && expression.callee.object.left.property?.value === "webpackChunk_N_E" && expression.arguments?.[0]?.elements?.[1]?.type === "ObjectExpression"
    12:50:36.330                                                                                         ^
    12:50:36.331    
    12:50:36.332    SyntaxError: Unexpected token '.'
    12:50:36.333        at wrapSafe (internal/modules/cjs/loader.js:1054:16)
    12:50:36.333        at Module._compile (internal/modules/cjs/loader.js:1102:27)
    12:50:36.333        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    12:50:36.333        at Module.load (internal/modules/cjs/loader.js:986:32)
    12:50:36.333        at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    12:50:36.334        at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    12:50:36.335        at internal/main/run_main_module.js:17:47
    12:50:36.344    Failed: build command exited with code: 1
    12:50:37.301    Failed: an internal error occurred
  • j

    James

    12/30/2022, 9:33 PM
    What's your
    NODE_VERSION
    env var set to? It'll need to be at least
    16
  • j

    James

    12/30/2022, 9:33 PM
    I'd also just be a little wary with
    next-on-pages
    if you run into any issues. Its state of maintenance and support right now is questionable, and I've seen others have more success with Netlify or Vercel for their projects.
  • n

    Nakedible

    12/31/2022, 3:45 PM
    Hey, I'm trying the next-on-pages thing as well, with "experimental-edge" runtime. And for me, it seems that routes like "[id].js" are not getting "query" or "params" in the context - is this normal?
  • j

    James

    12/31/2022, 4:25 PM
    That doesn’t sound normal, no. I’d recommend filing an issue on the repo but it might be some time until you hear anything back 🙁
  • n

    Nakedible

    12/31/2022, 5:25 PM
    Apparently there is already an issue... https://github.com/cloudflare/next-on-pages/issues/35
  • e

    Epailes

    01/01/2023, 5:04 PM
    That's the iffy thing about next-on-pages, for the other frameworks like remix/sveltekit pages support is maintained primarily by the framework devs alongside the other ecosystems so it's mostly kept up to date, vercel don't have anything to do with this package so it's just cloudflare/community. Hopefully due to how in demand next-on-pages is it'll grow and get strong community support, but if you want to actually use in production at the moment it's likely not the best choice. At least that's my take on things atm, Greg did respond to a bunch of PRs a couple of days ago it is making progress.
  • n

    Nakedible

    01/01/2023, 11:25 PM
    I love next as a framework, but I hate the fact that they steer things quite heavily towards Vercel. Every new release breaks everything for other users, making vercel the only option if you want to use the latest and greatest. And it seems even intentional rather than accidental. So for that reason, I will never use Vercel for anything. But yes, hopefully we'll slowly crawl towards more support. At least the next-on-pages stuff is public, unlike the things they do at AWS Amplify to make next work, so it's easier to fix it myself if necessary.
  • b

    bkyerv

    01/02/2023, 3:48 AM
    after minor updates to pages project (using astrobuild) started getting an error on every pages that uses functions. The error says
    "Error: To use the new ReadableStream() constructor, enable the streams_enable_constructors feature flag."
    . Has someone come across similar error? what could be the reason for this error message? I have not change anything substantially in the functions
  • a

    akshay

    01/02/2023, 5:59 AM
    Thanks, I'm using Node 18. I feel the same though - seems like an intern project and no real effort being put to maintain it. I would have love to have cloudflare host the website given their network PoPs, but you are right choosing Vercel or Netlify might be the more sane thing to do.
  • d

    denniarems

    01/02/2023, 6:36 AM
    how to skip npm installation in cloudflare pages ?
  • a

    aravindhan.dev

    01/02/2023, 6:50 AM
    How to deploy functions for static sites?
  • j

    JustinNoel

    01/02/2023, 11:18 PM
    Give it a try? Or send me a code sample of exactly what you're trying to do and I can try.
  • r

    rising_phoenix

    01/03/2023, 7:47 AM
    tldr: My functions go undetected and paths are giving 404 I have a Hugo site, where I am trying to add functions. I am adding functions/helloworld.js to the public folder and pushing it via wrangler direct upload. For some reason, the
    /helloworld
    URL gives 404 and even the function itself is undetected in the Cloudflare dashboard even though I can see that the file is uploaded. Am I missing something, should I compile js something like that?
  • k

    kian

    01/03/2023, 8:21 AM
    Functions folder shouldn’t be in the public folder
  • v

    Vero 🐙

    01/03/2023, 9:20 AM
    Hey @bkyerv Sounds like your code relies on the Streams constructors flag but your project isn't setup for it - you can change the compatibility date to be more recent or add that individual flag (see the images)
  • b

    bkyerv

    01/03/2023, 9:51 AM
    thank you! how are we - users of cloudflare - supposed to be aware of it? in future, is there any way to automatically set the comp date to the latest one? I doubt anyone would opt out of something that may brake production deploy
  • k

    kian

    01/03/2023, 9:52 AM
    Automatically using the newest compatibility date would break production - that's why they exist
  • k

    kian

    01/03/2023, 9:52 AM
    The only way that you'd need that flag is if your code is depending on behaviour that is behind that flag.
  • v

    Vero 🐙

    01/03/2023, 11:15 AM
    Hey @denniarems if there's no package.json we won't run npm install.
1...323324325...392Latest