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

    hanpolo

    02/24/2023, 12:54 AM
    I put it at project root .. now on same directory as functions .. still same. Let me try --persist now see what happens
  • h

    hanpolo

    02/24/2023, 12:56 AM
    Thanks for your patience .. that worked
  • h

    hanpolo

    02/24/2023, 1:11 AM
    I put it at project root .. now on same directory as functions .. still same. Let me try --persist now see what happens YES !!!!!๐Ÿ˜† ๐Ÿ’ฏ Thanks for your patience .. that worked I guess the problem is that I could not find the documentation for --persist using
    npx wrangler -h
  • z

    zszszsz

    02/24/2023, 1:12 AM
    yeah
  • z

    zszszsz

    02/24/2023, 1:13 AM
    You can find it here https://developers.cloudflare.com/workers/wrangler/commands/
  • j

    JustinNoel

    02/24/2023, 12:38 PM
    What I've done is just have a route like
    /seed-user
    and have the worker put in whatever you need. I've also added an authentication check to this to make sure no one can randomly hit this route.
  • h

    hanpolo

    02/24/2023, 9:52 PM
    Hi Folks, a new question. I'm trying to pass on data from my middleware authenticator to my api. I put data in context.data and then call context.next(). In the middleware I verify that there is data in context.data with a console.log. However, when my api function is subsequently called, context.data is empty. Any thoughts on how to make this work? I also noticed that context.next has a couple of parameters, and was wondering if these would have any effect, but I can't find much information on what the effect of these parameters are.
  • h

    hanpolo

    02/24/2023, 9:53 PM
    Thanks for the response, Justin.
  • h

    hanpolo

    02/25/2023, 12:23 AM
    It seems this may be a bug according to the response here: https://community.cloudflare.com/t/what-is-context-data-in-pages-functions/476559/5
  • s

    Skye

    02/25/2023, 12:27 AM
    There's an explanation here https://github.com/cloudflare/workers-sdk/issues/2797
  • s

    Skye

    02/25/2023, 12:27 AM
    TLDR, don't use
    context.data = { ... }
    , but instead
    context.data.foo = ...
  • h

    hanpolo

    02/25/2023, 12:30 AM
    Yes .. fantastic .. that solved it.๐Ÿ’ฏ
  • a

    ajgeiss0702

    02/26/2023, 6:35 PM
    is there any way to debug deployed functions? I'm getting
    Internal Error
    when its deployed to cloudflare pages, but when I test locally (using wrangler) it works perfectly.
  • e

    Erisa | Support Engineer

    02/26/2023, 6:37 PM
    ?pages-logs
  • h

    Helpflare

    02/26/2023, 6:37 PM
    If you're looking to tail a Pages Function you can do so in the UI here: https://dash.cloudflare.com?to=/:account/pages/view/:pages-project/:pages-deployment/functions or with Wrangler:
    wrangler pages deployment tail [deploymentId/url]
  • e

    Erisa | Support Engineer

    02/26/2023, 6:38 PM
    this will let you stream the logs, if you reproduce the error while streaming logs you should see the exception in there
  • a

    ajgeiss0702

    02/26/2023, 6:38 PM
    ah, thank you. i swear i looked around the ui for like 30 mins but couldnt find that ๐Ÿ˜„
  • a

    ajgeiss0702

    02/26/2023, 6:46 PM
    hm, why would i be getting a code 1003 to a request of a non-cloudflare domain?
  • j

    James

    02/26/2023, 6:48 PM
    Are you trying to
    fetch('some.ip.address')
    ?
  • j

    James

    02/26/2023, 6:48 PM
    Can you share your code? You can't
    fetch
    direct IP addresses for example though
  • a

    ajgeiss0702

    02/26/2023, 6:50 PM
    ah ok good to know
  • a

    ajgeiss0702

    02/26/2023, 6:50 PM
    yes i am
  • j

    James

    02/26/2023, 6:51 PM
    Yeah unfortunately that won't work. You'll need to create a DNS record for it
  • a

    ajgeiss0702

    02/26/2023, 6:51 PM
    i actually already had one for it, just the ip address was easier access at the time ๐Ÿ˜…
  • a

    ajgeiss0702

    02/26/2023, 6:59 PM
    hm, now i have a slightly different issue. When testing locally using wrangler, it receives json data perfectly, but when deployed, it just receives an empty string (but I see no request on the server its contacting)
  • a

    ajgeiss0702

    02/26/2023, 6:59 PM
    does it need to be https or something?
  • a

    ajgeiss0702

    02/26/2023, 7:03 PM
    I have this code for debugging:
    Copy code
    js
    const userDataRaw = await fetch("http://my.domain.com:25394/getInfo?id=" + encodeURIComponent(id))
        .then(r => r.text());
    console.log("response: " + userDataRaw);
  • k

    kian

    02/26/2023, 7:03 PM
    Custom ports don't really work either
  • a

    ajgeiss0702

    02/26/2023, 7:04 PM
    hm, ok then
  • a

    ajgeiss0702

    02/26/2023, 7:04 PM
    guess ive got to set up an origin rule or something ๐Ÿ˜„
1...351352353...392Latest