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

    HardAtWork

    11/25/2022, 10:03 AM
    Every system that uses Functions for SSR requires a connector of some kind. Outside of that connector, you shouldn't be directly interacting with Functions.
  • r

    rodbs

    11/25/2022, 10:19 AM
    ok, I'll try to learn more in the Remix discord!! thx!
  • p

    Pause

    11/25/2022, 8:46 PM
    Are there any updates on service bindings in Pages?
  • r

    rage5quid

    11/25/2022, 8:47 PM
    I want to use workers to create an api, should I create one function per endpoint or would it be better to create a worker with routing? What are the pros and cons?
  • w

    Walshy | Pages

    11/25/2022, 8:49 PM
    not yet
  • w

    Walshy | Pages

    11/25/2022, 8:50 PM
    Pros: - Integrated with your project, so they get deployed at the same time - Available on pages.dev - They are just Workers anyway Cons: - /shrug
  • r

    rage5quid

    11/25/2022, 8:51 PM
    Haha, thanks
  • t

    Thanh Nguyen

    11/26/2022, 4:44 AM
    how do I eliminate the eslint errors about Functions APIs not being defined
  • p

    Pause

    11/26/2022, 5:05 AM
    What is a good way to trigger middleware on GET requests for web pages only (and not other static assets, e.g. images, or other API requests)?
  • p

    Pause

    11/26/2022, 5:05 AM
    Do I need to maintain a list of exclusions?
  • p

    Pause

    11/26/2022, 5:07 AM
    I want to run an HTMLRewriter on all web pages and then stick the rewriter in
    data
    so it can be reused.
  • b

    bkyerv

    11/26/2022, 12:59 PM
    Hello everyone, I am building a simple app to try pages/function/r2. When I test the app locally (running
    wrangler pages dev --persist --r2=PIC -- npm run dev
    ) everything seems to work with no errors, however when I deploy the app using cf pages UI of the app works with no errors but any attempt to trigger functions result in errors. On the client (i.e. in the console tab of the devtools section of the browser) I see
    internal server error 500
    , on the backend
    wrangler pages deployment tail
    I see
    Error: network connection lost
    . Initially I built the app using astro/vanillajs but then tried vite/react thinking that the error might be specific to astro, however the error persists
  • b

    bkyerv

    11/26/2022, 1:01 PM
  • b

    bkyerv

    11/26/2022, 1:03 PM
    when I run
    wrangler pages dev --persist --r2=PIC -- npm run dev
    to test locally the app is available on both port 5173(default for vite) and port8788(default for wrangler/workerd?). The one that is available on port 8788 works well while the one available on port 5173 results in same type of errors as the one on the prod (ie
    [project-name].pages.dev
    )
  • a

    aautio

    11/26/2022, 1:31 PM
    Not sure if this is related, but you are missing
    await
    from the
    fetch("/api/upload", ...)
    in the first screenshot. Without
    await
    the code execution does not wait for network request to finish before printing out
    end calling api
    . Might be worth trying it out:
    await fetch("/api/upload", ...)
  • b

    bkyerv

    11/26/2022, 1:36 PM
    Thank you. I am using
    .then
    to handle the async part. I will try to replace with await but I feel that whole this error has something to do with deploy. It seems like requests I am making are not directed to functions and therefore return some weird errors
  • z

    zsmooth

    11/26/2022, 1:39 PM
    You still have to return that fetch call, even if you use then.
  • a

    aautio

    11/26/2022, 1:39 PM
    You can keep the
    .then()
    , no need to remove it. Just do
    await fetch("/api/upload", ...).then(...)
    to make sure the whole promise chain is resolved before the execution continues to the line printing
    end calling api
    . But yep this is likely not related to your original issue :/
  • z

    zsmooth

    11/26/2022, 1:39 PM
    (Either return it, or await it) but yeah, not related.
  • z

    zsmooth

    11/26/2022, 1:44 PM
    Is the repo public on GitHub?
  • b

    bkyerv

    11/26/2022, 1:46 PM
    https://github.com/bkyerv/r2-demo
  • z

    zsmooth

    11/26/2022, 1:51 PM
    Does the save-url function work?
  • b

    bkyerv

    11/26/2022, 1:51 PM
    yes, that one returns url as expected (string value)
  • z

    zsmooth

    11/26/2022, 1:52 PM
    Hmm, and it all works locally on :8788?
  • b

    bkyerv

    11/26/2022, 1:52 PM
    correct
  • b

    bkyerv

    11/26/2022, 1:53 PM
    this is 4th day I am struggling to solve this issue
  • b

    bkyerv

    11/26/2022, 1:53 PM
  • b

    bkyerv

    11/26/2022, 1:53 PM
    here is the build confs
  • b

    bkyerv

    11/26/2022, 1:54 PM
    I can confirm that build artefacts end up in the
    dist
    folder
  • z

    zsmooth

    11/26/2022, 2:05 PM
    and you have the R2 bucket binding set up?
1...312313314...392Latest