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

    dave

    11/21/2022, 1:40 PM
    I would be worried about side channels with using an external JavaScript library.
  • d

    dave

    11/21/2022, 1:44 PM
    https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html
  • d

    dave

    11/21/2022, 1:45 PM
    No worries. Lemme know if I can help test anything!
  • f

    fbars

    11/21/2022, 5:25 PM
    Hello, I am attempting to migrate my next.js app from vercel to pages, and the issue I am facing is with dynamic pages leading to a 404. Any help would be greatly appreciated.
  • f

    fbars

    11/21/2022, 5:26 PM
    I found this documentation - https://developers.cloudflare.com/pages/platform/functions/routing/ . Do I need to create a worker as well?
  • p

    peppersghost

    11/21/2022, 6:05 PM
    I'm trying to do "wrangler tail" on my Pages functions, but I get no output when calling my function, am I missing something?
    • 1
    • 1
  • c

    chrisjmccreadie

    11/21/2022, 6:22 PM
    @fbars are long you put them in a folder called functions
  • c

    chrisjmccreadie

    11/21/2022, 6:23 PM
    here is an example layout for one of my prjects
  • c

    chrisjmccreadie

    11/21/2022, 6:23 PM
  • c

    chrisjmccreadie

    11/21/2022, 6:23 PM
    so http://localhost:8788/api/build/ would route to build.js and so on
  • c

    chrisjmccreadie

    11/21/2022, 6:28 PM
    @peppersghost do you use wrangler pages deployment tail
  • c

    chrisjmccreadie

    11/21/2022, 6:28 PM
    ?
  • p

    peppersghost

    11/21/2022, 6:31 PM
    Lifesaver! I must have missed this in the docs.
  • c

    casdr

    11/21/2022, 7:49 PM
    Hi! I'm trying to get the POST body in a function, but I cannot find how to do this. I've tried using the following: https://pastebin.breedband.nl/p/OL5O5vsTGJQwDhBi7jET4SCr Can anyone help me with this?
  • k

    kian

    11/21/2022, 7:51 PM
    await request.json()
  • c

    casdr

    11/21/2022, 7:51 PM
    I've also tried request.json() in the past, which gave me an error, but I'm trying this again
  • c

    casdr

    11/21/2022, 7:52 PM
    Maybe I did something wrong 🙂
  • z

    ziwar

    11/21/2022, 7:56 PM
    With the new changes in Pages Functions, is it now possible to do things like Deferred Static Generation or Incremental page generation such as the ones that Gatsby cloud supports?
  • c

    casdr

    11/21/2022, 8:01 PM
    https://pastebin.breedband.nl/p/M3REJGwEYZwWAivK0zUUm7ah This gives me an error (Worker threw exception)
  • k

    kian

    11/21/2022, 8:02 PM
    is it actually valid json in the request body
  • k

    kian

    11/21/2022, 8:02 PM
    change json() to text()
  • c

    chrisjmccreadie

    11/21/2022, 8:05 PM
    I do this return new Response(JSON.stringify(result), { status: 200 });
  • c

    casdr

    11/21/2022, 8:12 PM
    https://pastebin.breedband.nl/p/VA0A7fFOTBkZAT7ImXgfdT1T still getting the same error
  • c

    casdr

    11/21/2022, 8:12 PM
    I have not idea where I can find the logs though
  • c

    casdr

    11/21/2022, 8:18 PM
    Ah I'm testing locally now:
    Copy code
    TypeError
    request.text is not a function
  • c

    casdr

    11/21/2022, 8:19 PM
    It's undefined apparently
  • c

    casdr

    11/21/2022, 8:20 PM
    Got it!
    request.request.json()
  • k

    kian

    11/21/2022, 8:22 PM
    change (request) to ({request})
  • k

    kian

    11/21/2022, 8:22 PM
    pages functions get context, not request
  • k

    kian

    11/21/2022, 8:22 PM
    you need to destructure it
1...309310311...392Latest