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

    Greg Brimble | Cloudflare Pages

    01/23/2022, 11:40 PM
    But why not just SSR those dynamic-ish pages?
  • i

    itsmatteomanf

    01/23/2022, 11:40 PM
    Plus, no need to have JS active.
  • i

    itsmatteomanf

    01/23/2022, 11:42 PM
    Because they are not actually that dynamic. The data is relatively static (but not fully), it's the same for everyone, I would need to actually set up full SSR, which is not working with
    nuxt
    on Workers. Maybe Nuxt 3...
  • i

    itsmatteomanf

    01/23/2022, 11:43 PM
    I could move that to the client, and I probably will on final publish, but I'm not gonna be the only one with this issue 🙂
  • g

    Greg Brimble | Cloudflare Pages

    01/23/2022, 11:43 PM
    Relatively static, like a blog post or something? So your concern is primarily that you'll need an SSR framework to render the page, but it's relatively easy to just give back the data in your API. And presumably secondarily, you think that SSR is overkill for a "relatively static" thing. Is that a good summary?
  • i

    itsmatteomanf

    01/23/2022, 11:44 PM
    Basically yeah.
  • g

    Greg Brimble | Cloudflare Pages

    01/23/2022, 11:44 PM
    Cool
  • i

    itsmatteomanf

    01/23/2022, 11:44 PM
    It also allows for the data to be processed on the server once and not on every client as it needs to be transformed in a couple ways.
  • g

    Greg Brimble | Cloudflare Pages

    01/23/2022, 11:45 PM
    That's interesting. Haven't really thought about this use-case, but we have discussed some adjacent stuff and maybe that could help. DMing.
  • m

    maximillian

    01/24/2022, 4:56 PM
    Hey y'all, I have a graphql api behind a function acting as a reverse proxy. All the URLs returned via this function seem to get rewritten to use
    https://
    instead of
    http://
    which is what I'm getting from the the raw API. Wtf is up
  • m

    maximillian

    01/24/2022, 4:57 PM
    (These are url strings in the actual query response body)
  • m

    maximillian

    01/24/2022, 4:58 PM
    I need to skip SSL in development because wrangler doesn't like my self signed certificate. It seems to work, but this weird URL rewriting is messing up the links returned from the API
  • r

    Rewl

    01/24/2022, 10:27 PM
    I can find documentation to test Workers locally. The Workers are very similar but not identical to the functions. Is there also a way to test functions locally?
  • j

    James

    01/24/2022, 10:57 PM
    Yep!
    wrangler pages dev
    essentially, via wrangler2 🙂 More info at https://github.com/cloudflare/wrangler2 and https://developers.cloudflare.com/pages/platform/functions#develop-and-preview-locally
  • r

    Rewl

    01/24/2022, 11:36 PM
    My function is compiled to a temp dir, and that looks fine. But I can't trigger it, even though it works on the pages site. My "functions" directory is in the root of my project, and static files are in "content", so I launch
    npx wrangler pages dev ./content/
    . (now I have two problems...)
  • r

    Rewl

    01/24/2022, 11:52 PM
    If I modify the function file, wrangler does pick it up and recompiles
  • r

    Rewl

    01/24/2022, 11:53 PM
    Compiled Worker successfully.
  • r

    Rewl

    01/25/2022, 1:13 AM
    After adding a
    ./content/404.html
    I can now confirm that the functions DO have the correct routing on
    <domain>.pages.dev
    but on my local machine give a 404. (Windows, latest npm/node)
  • r

    Rewl

    01/25/2022, 1:16 AM
    The
    functionsRoutes.mjs
    and
    functionsWorker.js
    look good to me.
  • z

    zsmooth

    01/25/2022, 4:00 AM
    If I'm getting a "Worker exceeded resource limits" error on my pages function, is the only way to find out what resource limit I'm hitting by filing a support ticket?
  • z

    zsmooth

    01/25/2022, 1:12 PM
    My error is 1102, which is CPU time. It returns almost immediately, so I assume Page uses the Bundled worker model? Is that correct, and if so, is there any way to change it? My account is configured for Unbound by default.
  • t

    taro

    01/25/2022, 10:42 PM
    can somebody point me to an example of a DO binding using wrangler2 pages dev? e.g.
    wrangler pages dev --do DO_NAME=CLASS_NAME
  • t

    taro

    01/25/2022, 10:43 PM
    if it helps, im trying to proxy rather than serve a static folder
  • t

    taro

    01/25/2022, 10:44 PM
    i had it working using an older version of wrangler2 a month ago, however the latest versions (alpha and beta) are telling me that the class binding cant be found
  • t

    taro

    01/25/2022, 11:41 PM
    ah nevermind (i think?) it appears that the
    pages
    branch (which i was using previously) hasnt been merged, thus miniflare
    mounts
    arent being used, which i believe is essential when using functions (i.e. without a given "advanced" workers script)
  • z

    zsmooth

    01/26/2022, 12:52 AM
    I thought Greg has said in the past that you can bind to existing DO’s, but you can’t create one via Pages…
  • m

    Mikkel

    01/26/2022, 4:15 PM
    👋 Is there a way to use NPM packages in Functions? The image host example has a package.json but it appears to be for the static React site not for the functions.
  • g

    geelen

    01/26/2022, 4:21 PM
    Yeah you should be able to import NPM packages from your function, as long as they're installed as part of your
    package.json
    . You can use
    wrangler pages dev
    to test things out locally before you push: https://developers.cloudflare.com/pages/platform/functions#develop-and-preview-locally
  • m

    Mikkel

    01/26/2022, 4:23 PM
    So my frontend and backend share a single package.json? Webpack is smart enough to only include the packages that are used?
  • g

    geelen

    01/26/2022, 4:26 PM
    it's esbuild, not webpack, but yeah it just starts at your files and crawls everything you import
1...686970...392Latest