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

    kian

    03/27/2023, 8:25 PM
    worker-rs is all hand-written bindings to the Workers APIs using wasm-bindgen and web-sys crates for the most part
  • k

    kian

    03/27/2023, 8:25 PM
    You’d have to write your own “glue” between C# and JS
  • w

    William.

    03/28/2023, 12:44 PM
    Time for my weekly question up : did anyone manage to use middleware on an angular CSR project yet ? my 14days old ticket still has no answer.
  • s

    silentdevnull

    03/28/2023, 1:03 PM
    Thank you for the information. I will have to do some research on how to do that. I haven't every done anything like that before.
  • w

    Walshy | Pages

    03/28/2023, 1:44 PM
    Never used Angular but doesn't the regular
    functions/_middleware.js
    work?
  • w

    William.

    03/28/2023, 1:44 PM
    It works only in wrangler basicly
  • w

    Walshy | Pages

    03/28/2023, 1:44 PM
    if it works in wrangler, it should work in prod
  • w

    William.

    03/28/2023, 1:45 PM
    Exactly 😄
  • w

    Walshy | Pages

    03/28/2023, 1:45 PM
    can you share more details?
  • w

    William.

    03/28/2023, 1:45 PM
    Sure
  • w

    William.

    03/28/2023, 1:46 PM
    It starts here
  • w

    Walshy | Pages

    03/28/2023, 1:49 PM
    what's your pages.dev?
  • w

    William.

    03/28/2023, 1:51 PM
    sent over DMs
  • m

    Michael-V

    03/28/2023, 2:41 PM
    I try since days to get my head arround it and googled so much ..... how can I have a html form on a static page with cloudflare pages and send an email to me with the form submission via cloudflare pages function? Have a look here: https://gist.github.com/michael-voit/6295d286331ff6049d0bd8b60d64a4ff I have a form in the html document (form.html), a form.js to prevent the default form submission behavior and instead "give it" to a cloudflare pages function sitting in a file contact.js in folder /functions/api I was able to test and iterate it to the point, that the first two steps are working - but it seems that contact.js is not transformed into a function - or something like that. Anybody has done that before? Or anyone time to look over it? THANKS SO MUCH IN ADVANCE!
  • h

    hanpolo

    03/28/2023, 6:32 PM
    Is there an equivalent of @Cloudflare/workers-types for functions written in Typescript. I would like to type context in onRequest( context ). I don't think the ExecutionContext from workers-types is right for functions.
  • d

    Dani Foldi

    03/28/2023, 6:34 PM
    yup, I think you should export a variable (or function) with type
    PagesFunction
    that gets one argument that receives an
    EventContext
    , which contains the
    ExecutionContext
  • h

    hanpolo

    03/28/2023, 6:35 PM
    ok so to verify: the context in onRequest( context ) has type EventContext?
  • d

    Dani Foldi

    03/28/2023, 6:36 PM
    correct - if you export it as
    export const onRequest: PagesFunction = (context) => { ... }
    , it pickes up argument and return types automatically
  • d

    Dani Foldi

    03/28/2023, 6:36 PM
    (edited, I'm tired)
  • h

    hanpolo

    03/28/2023, 6:38 PM
    Thanks much. That one worked like a charm 🙂
  • b

    botabit

    03/28/2023, 7:49 PM
    Following docs here (https://developers.cloudflare.com/pages/platform/functions/advanced-mode/#set-up-a-function), using example code. Getting deployment error
    Transforming async functions to the configured target environment ("es5") is not supported yet
  • b

    botabit

    03/28/2023, 7:50 PM
    Trying to fix the routing for two SPAs hosted under the same pages project
  • b

    botabit

    03/28/2023, 7:52 PM
    Route
    /*
    maps to SPA 1 but I want to map
    /spa2/*
    to SPA 2
  • h

    HardAtWork

    03/28/2023, 7:53 PM
    That looks like something is trying to bundle the _worker.js file, which it shouldn’t be doing. Where do you have it?
  • b

    botabit

    03/28/2023, 7:53 PM
  • b

    botabit

    03/28/2023, 7:53 PM
    It might be the routes.json file
  • h

    HardAtWork

    03/28/2023, 7:54 PM
    _worker.js should be in the output directory, not in the
    functions
    folder
  • b

    botabit

    03/28/2023, 7:55 PM
    thanks, so it should be copied into
    /dist
    during the build step?
  • h

    HardAtWork

    03/28/2023, 7:56 PM
    Yes
  • s

    syon

    03/28/2023, 8:40 PM
    Hi sorry if I'm blind but looking for a needle in the haystack it looks like this feature is under active development and I do like the direction it is going. My question is there a cheat seat or where is the code that calls our pages functions? Do you know how it works when we export an
    onRequest
    method. I noticed you use
    onRequestPost
    do all https request methods work like this Can I export onRequestGet, onRequestPost, and onRequest all in the same route. Would onRequest get everything or would the more specific one win. Is there a place where everything available from cloudflair in pages functions is documented For example waitUntil kv d1 etc. I noticed here I need a list of modules to import and their interfaces. or available functions that can be exported. If there is a spec doc for the routing naming that might be nice. Or something if anyone has that in a project somewhere 🙂 Let me know what you have found
1...364365366...392Latest