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

    TrickMatt

    03/30/2022, 3:53 AM
    Is access to headers not implemented in Cloudflare Pages Function onRequest handlers - e.g. return new Response("Hi: " + context.request.headers['User-Agent']) returns response of "Hi: undefined" to a GET request from a normal browser
  • t

    TrickMatt

    03/30/2022, 3:53 AM
    return new Response(JSON.stringify(context.request.headers)) and return new Response(JSON.stringify(new Map(context.request.headers))) also yield empty maps expecting a least to see User-Agent, Accept, etc..
  • t

    TrickMatt

    03/30/2022, 5:09 AM
    Nevermind, figured it out, need to use .get / .entries etc as described by MDN
  • t

    TrickMatt

    03/30/2022, 5:20 AM
    Where I can I get the logs for Pages functions - e.g. a function throws an exception Error 1101 Ray ID: 6f3e61962c44879d • 2022-03-30 05:17:50 UTC Worker threw exception
  • t

    TrickMatt

    03/30/2022, 5:20 AM
    Does not show in Workers
  • c

    Chaika

    03/30/2022, 5:33 AM
    You can't see them right now, you could try deploying the same code to workers or using something like miniflare/wranglerv2 (which should show some more info/replicate the issue)
  • t

    TrickMatt

    03/30/2022, 5:43 AM
    Is there any plans to be able to grant team members access to see build status and specific pages config instead of just Administrator or Super Administrator for the whole account?
  • t

    TrickMatt

    03/30/2022, 5:43 AM
    Is there any plans to provide build hooks - slack notifications perhaps of build issues?
  • “Pages” as an RBAC role is on the
    k

    kian

    03/30/2022, 6:26 AM
    “Pages” as an RBAC role is on the roadmap for Enterprise
    c
    s
    • 3
    • 5
  • s

    Spell

    03/30/2022, 6:31 AM
    Is the Register Domains page down or is it just me?
  • j

    JustinNoel

    03/30/2022, 11:37 AM
    No secrets for Functions right now. However, the CF team is aware of this and sounded amenable to adding real secrets. So, in the meantime, use environment variables.
  • r

    raduab

    03/30/2022, 12:31 PM
    There are times when Pages Functions gives errors. It works properly, until Cloudflare issues a 404, then it works again when refreshing. What could be the problem with that?
  • s

    syrokos

    03/31/2022, 1:17 AM
    Is it possible to route a worker to a cloudflare hosted page that already has a functions folder? would removing the functions folder allow me to route a worker?
  • t

    TrickMatt

    03/31/2022, 1:28 AM
    Is there a reason axios does not work in functions? Someone suggested it depends on Node specific APIs however since is also compatible with the browser I thought it would fall back to browser APIs?
  • i

    Isaac McFadyen | YYZ01

    03/31/2022, 1:29 AM
    It depends. Cloudflare Workers aren't always detected as needing browser libraries. I would bet that Axios doesn't do the check correctly, assumes Node.JS, then fails.
  • i

    Isaac McFadyen | YYZ01

    03/31/2022, 1:30 AM
    Does Axios work in a Worker?
  • i

    Isaac McFadyen | YYZ01

    03/31/2022, 1:30 AM
    (no pun intended haha)
  • t

    TrickMatt

    03/31/2022, 1:30 AM
    Thanks, is there a decent abstracted HTTP library that works everywhere (cf pages functions and node stable lts at least) - e.g. I cant mocha test fetch without some edge version of node with experimental flags
  • t

    TrickMatt

    03/31/2022, 1:31 AM
    @User only experimented with CF Page functions atm
  • i

    Isaac McFadyen | YYZ01

    03/31/2022, 1:31 AM
    Hmm, it depends on what you need.
  • i

    Isaac McFadyen | YYZ01

    03/31/2022, 1:31 AM
    What's the problem with just a
    fetch
    ?
  • t

    TrickMatt

    03/31/2022, 1:31 AM
    Doesnt work in node
  • i

    Isaac McFadyen | YYZ01

    03/31/2022, 1:31 AM
    It does on v17 with a flag.
  • i

    Isaac McFadyen | YYZ01

    03/31/2022, 1:31 AM
    https://blog.logrocket.com/fetch-api-node-js/
  • t

    TrickMatt

    03/31/2022, 1:31 AM
    yep, will be a while before thats non experimental
  • i

    Isaac McFadyen | YYZ01

    03/31/2022, 1:32 AM
    Yeah. In which case, I don't know of one, unfortunately.
  • t

    TrickMatt

    03/31/2022, 1:32 AM
    okay thanks
  • a

    aust.crim

    03/31/2022, 2:48 AM
    just went down a little rabbit-hole but wanted to confirm here: You can pass the
    --kv NAMESPACE
    flag to
    wrangler pages dev
    but it will not actually connect to your live KV namespaces (production or preview). i have existing data in a KV namespace but i can't interact with it during local development. the
    —local false
    flag does not work yet. Is this true or am i missing something?
  • k

    Keenwau

    03/31/2022, 4:03 AM
    Yes, it creates a folder called
    .mf/kv
    and has no bearing on the Production or Preview namespaces you find on
    dash.cloudflare.com
  • a

    aust.crim

    03/31/2022, 12:50 PM
    Ok, bummer. I was hoping there was some way I could connect to my existing data.
1...110111112...392Latest