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

    rdutton

    01/25/2023, 3:13 AM
    It's just a personal project, that I might share if it's gets to that point. I'm kind of doing it as an exercise to see how this stuff works. Ideally, I'd like to be able to develop locally, check in changes and have it magically work in Cloudflare. Which might be wishful thinking but it's 'almost there'
  • i

    i40west

    01/25/2023, 3:15 AM
    Not wishful thinking at all.
  • r

    rdutton

    01/25/2023, 3:15 AM
    I'll look at whether I can include something into the build instructions to produce the _worker.js using esbuild as you suggested
  • i

    i40west

    01/25/2023, 3:15 AM
    Yeah, just add a build command to
    package.json
    that does the build and make sure it runs as part of
    npm run build
    or whatever. Then you can have your output files in
    .gitignore
    and let it build cleanly at Cloudflare
  • i

    i40west

    01/25/2023, 3:16 AM
    (as long as you don't need the latest version of Node, we're still waiting for the v2 build image for that)
  • r

    rdutton

    01/25/2023, 3:18 AM
    Thanks for your help, that's really useful info. I did come across Node version issue, fortunately it was easy enough to work-around.
  • r

    rdutton

    01/25/2023, 3:18 AM
    I'll do some reading.. and let you know how I go 🙂
  • r

    rdutton

    01/25/2023, 6:28 AM
    Thank you @i40west for the advice. I am now bundling my worker code to _worker.js for my pages project using esbuild
    esbuild --format=esm --bundle --sourcemap --outfile=dist/_worker.js ./src_worker/index.js
    with the critical flag being
    --format=esm
    and it's deploying successfully 🙂
  • g

    Greg Brimble | Cloudflare Pages

    01/25/2023, 8:03 AM
    We are working on supporting bundling with
    _worker.js
    but it’s not quite ready for debut. Stay tuned!
  • r

    rdutton

    01/25/2023, 9:03 AM
    That would be handy and to be honest what I was expecting.. though now I understand more of what is going on, it's reasonable that it doesn't do it for you.
  • v

    Vero 🐙

    01/25/2023, 5:43 PM
    Hey @ZøD? and @Uxbert FE, a lot of members have been asking for more attention for next-on-pages, I've been sending your feedback to the team, and they are aware of that, right now they are focusing on other items but also plan to give a bit more attention to this
  • z

    zszszsz

    01/25/2023, 6:35 PM
    So is the v2 build image coming soon ?
  • g

    Greg Brimble | Cloudflare Pages

    01/25/2023, 6:54 PM
    Still no date we can commit to, I'm afraid :/
  • s

    Someone

    01/26/2023, 5:30 AM
    is it possible to set/append new headers to the response object within an onRequest() method for a CF pages function? When I attempt the below, i don't see the custom header attached in the network tab, but it successfully returns the body.
    Copy code
    export async function onRequest(context){
      const body = JSON.stringify("foo": "bar");
      let response = new Response(body); 
      response.headers.set("X-Numbers", "123");
      return response
    }
  • i

    IanVS

    01/26/2023, 9:50 PM
    Has anyone here heard of middleware intermittently breaking cached responses? I added the sentry plugin, and my site went to pieces. https://github.com/cloudflare/pages-plugins/issues/23
  • j

    James

    01/27/2023, 12:02 AM
    Are you seeing this locally with
    wrangler dev
    using the latest wrangler 2.8.1, in prod, or both?
  • j

    James

    01/27/2023, 12:03 AM
    There were some fixes to Pages Plugins in wrangler 2.7.0 - but I'm not entirely sure if that covers your issue
  • i

    IanVS

    01/27/2023, 12:11 AM
    I'm seeing it in prod, using https://github.com/cloudflare/pages-action v1.3.0. I'll try using wrangler dev, but since that's a local dev server I assume it's quite different from prod.
  • j

    James

    01/27/2023, 12:11 AM
    What version of wrangler are you using? Are you pinned to a specific version in your
    package.json
    ?
  • i

    IanVS

    01/27/2023, 12:12 AM
    Copy code
    ▶ npm ls wrangler
    defined-www@1.0.0 /Users/ianvs/code/defined/www
    └── wrangler@2.7.1
  • i

    IanVS

    01/27/2023, 12:17 AM
    Works fine with
    npx wrangler pages dev
  • g

    Greg Brimble | Cloudflare Pages

    01/27/2023, 2:01 AM
    https://discord.com/channels/595317990191398933/1068280215563944097/1068349934803361844
  • i

    IEatBeans

    01/27/2023, 5:16 AM
    Hey, is it possible to upload an image file? Im trying to get the file from formdata , and if i print it it says
    Blob { size: 8880, type: 'image/png' }
    , but then when i try to set it to the formdata of a fetch inside the function it says
    Failed to execute 'append' on 'FormData': 2 arguments required, but only 1 present
  • i

    IEatBeans

    01/27/2023, 5:17 AM
    oh, never mind lol. i assumed it was that, but it was just a typo lmao
  • d

    demluxe

    01/29/2023, 12:52 AM
    is there a way to see the output of a console log that happens in an edge function?
  • j

    James

    01/29/2023, 12:54 AM
    You can get live logs with
    wrangler pages deployment tail
    , but you won't be able to see any historical logs
  • j

    James

    01/29/2023, 12:54 AM
    If you need historical logs, I'd recommend piping things off manually to sentry, honeycomb, etc.
  • d

    demluxe

    01/29/2023, 12:55 AM
    Thank you
  • h

    Hazard

    01/29/2023, 1:39 AM
    Is it not possible to open WebSocket connection in a cloudflare function? Getting this error:
    ERROR Error: Failed to construct 'WebSocket': the constructor is not implemented.
  • i

    IEatBeans

    01/29/2023, 5:12 AM
    What would be the best way to structure my api if some endpoints require authentication? Im currently using middleware and its great, but since it uses the file path its not very clean. Say i have these endpoints:
    Copy code
    GET /server/list OPEN
    GET /server/[uuid]/details OPEN
    POST /server/[uuid]/details AUTH
    POST /server/[uuid]/images/logo AUTH
    Where would I put the middleware?
1...339340341...392Latest