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

    geelen

    11/19/2021, 10:11 AM
    ah yep ok, basically if you wrap the majority of your app in a try catch and collect errors to sentry or something
  • g

    Greg Brimble | Cloudflare Pages

    11/19/2021, 10:11 AM
    https://github.com/robertcepa/toucan-js#equivalent-of-above-as-a-module-mjs
  • b

    boojum

    11/19/2021, 10:20 AM
    I'm trying to implement CORS proxy (copy of https://developers.cloudflare.com/workers/examples/cors-header-proxy really) via Pages Functions. The example repo is here - https://gitlab.com/b00jum/marketplace, deployed to https://marketplace-9xy.pages.dev/. The idea is to fire the cors proxy function on any requests containing
    /corsproxy
    segment in the url path. But I think that I got function routing wrong as I'm getting 404. I would appreciate any debugging pointers!
  • i

    ickerio

    11/19/2021, 10:54 AM
    Are you able to define DOs in your pages app? Or does that have to be done separately with wrangler?
  • h

    hannes

    11/19/2021, 10:55 AM
    2 questions: 1) will service bindings come to Pages eventually? so we can eventually pass /api to a versioned service. Or is it intended that those 2 "worlds" stay separate forever; asking because building new system and sill unsure if pages will be scalable enough for the amount of logic/appcode coming.. [edit: realizing you can just fetch a worker.dev service now, but question is more about efficiency in the future)] leading to.. 2) is the 1MB script limit already lifted for pages functions? if not, will it be? as we merge several functions it's now easier conceptually to hit the limit
  • g

    Greg Brimble | Cloudflare Pages

    11/19/2021, 10:56 AM
    That repo is private.
  • g

    Greg Brimble | Cloudflare Pages

    11/19/2021, 10:57 AM
    Separately, and with wrangler v1, for now. We're working on bridging this gap and making it a more seamless experience, but haven't quite figured out what that looks like yet.
  • i

    ickerio

    11/19/2021, 10:57 AM
    Thanks Greg!
  • b

    boojum

    11/19/2021, 10:58 AM
    My bad! It's public now.
  • g

    Greg Brimble | Cloudflare Pages

    11/19/2021, 11:01 AM
    Looks like your function is setup correctly: https://marketplace-9xy.pages.dev/corsproxy/search?term=greg&entity=song does indeed do things with apple.com, so your 404 problem must be a failure to build/deploy your static assets.
  • g

    Greg Brimble | Cloudflare Pages

    11/19/2021, 11:01 AM
    Do you have your build command/build output directory set correctly?
  • b

    boojum

    11/19/2021, 11:06 AM
    This whole things is based off https://github.com/lukeed/pages-fullstack and uses build command/build output directory/node version as prescribed there. The thing is, if I remove the corsproxy function, the "app" works - or renders - but produces the "Access-Control-Allow-Origin" CORS error.
  • p

    Ponjimon

    11/19/2021, 12:43 PM
    Not sure if this is the right channel, but I'm currently trying to have a full-stack app using NextJS as the frontend and then instead of using NextJS's API functionality (which would be nice but guess not supported) I'll be using functions. I also want to test
    wrangler@beta
    so I run this command:
    wrangler pages dev -- yarn run ui:dev
    which translates to
    wrangler pages dev -- next
    . Running
    next
    just starts the local dev environment of NextJS. I have a file
    src/pages/index.tsx
    that basically just is a hello world React component and a file
    functions/index.ts
    that again is just a hello world
    onRequestGet
    function. My problem is, that in the console I see it serving at
    http://127.0.0.1:8788
    but when I open that, it just is the API / functions route I created, how do I access the UI (which next by default serves at port 3000) and how can I then make HTTP requests to the API? I've seen some code on GitHub where they use
    await fetch('/someFunctionRoute')
    but I don't really understand how I make that work with NextJS
  • p

    Ponjimon

    11/19/2021, 1:43 PM
    Okay, doesn't have to do with what I do at all, getting similar behavior using this https://github.com/twhitbeck/shortr-cf
  • k

    kavinplays

    11/19/2021, 2:45 PM
    having it cached can possibly be faster, but i think that will be more expensive if you use bundled workers
  • w

    wonkrattle

    11/19/2021, 3:50 PM
    Is there a good like for dummies introduction to functions? I feel like this is incredibly useful to people who only know HTML and liquid, but it’s demonstrably more complicated because you have to know JavaScript.
  • k

    kavinplays

    11/19/2021, 3:52 PM
    like a rundown for javascript?
  • k

    kavinplays

    11/19/2021, 3:52 PM
    it's essentially what you would use with html and css
  • w

    wonkrattle

    11/19/2021, 3:52 PM
    Like, here are some extremely basic things you might want to do if you have a Jekyll blog (inject a line of text)
  • w

    wonkrattle

    11/19/2021, 3:53 PM
    Right but you’re assuming that most people who use Jekyll are writing meaningful amounts of JavaScript
  • w

    wonkrattle

    11/19/2021, 3:54 PM
    If you’re using an off-the-shelf theme, it’s remarkably easy to build a full featured site without ever touching JavaScript
  • k

    kavinplays

    11/19/2021, 3:54 PM
    no, i am assuming most people who don't use javascript, prolly don't need to use functions
  • w

    wonkrattle

    11/19/2021, 3:55 PM
    Right but I think that’s incorrect. There’s plenty of functionality offered by functions that has nothing to do with formatting
  • w

    wonkrattle

    11/19/2021, 3:56 PM
    Like if your page is just let me present some information, there’s a huge benefit to using functions, but you might have zero need to use client-side JavaScript
  • k

    kavinplays

    11/19/2021, 3:57 PM
    yup, but it's built on the same javascript, not everyone uses jerkyll and there's way too many variables for what everyone uses
  • k

    kavinplays

    11/19/2021, 3:57 PM
    slowly, community based guides come out for this
  • k

    kavinplays

    11/19/2021, 3:57 PM
    like the discord slash bot on workers
  • w

    wonkrattle

    11/19/2021, 3:58 PM
    Right that’s what I’m asking for. And I do think that you know given that people are migrating to Cloudflare pages from GitHub pages which is based in Jekyll, it’s not an unreasonable idea for them to specifically build Content around that.
  • k

    kavinplays

    11/19/2021, 3:59 PM
    right, but from what i have seen here, the majority of people are not using jerkyll
  • w

    wonkrattle

    11/19/2021, 4:01 PM
    You mean on this discord? That’s probably because most people deploying a Jekyll site aren’t doing anything that needs help at the moment. The documentation is extremely good and you only have to click a few buttons.
12345...392Latest