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

    Isaac McFadyen | YYZ01

    04/16/2022, 10:43 PM
    Is
    request.url
    used up, or is that only the body?
  • i

    Isaac McFadyen | YYZ01

    04/16/2022, 10:43 PM
    I can't remember.
  • j

    James

    04/16/2022, 10:44 PM
    URL isn't used up, but yeah
    url
    is definitely dead here, copied from my other code
  • i

    Isaac McFadyen | YYZ01

    04/16/2022, 10:44 PM
    Waiiit.
  • i

    Isaac McFadyen | YYZ01

    04/16/2022, 10:44 PM
    I thought you sent a URL into env.ASSETS.fetch?
  • i

    Isaac McFadyen | YYZ01

    04/16/2022, 10:44 PM
    Like as a string?
  • i

    Isaac McFadyen | YYZ01

    04/16/2022, 10:45 PM
    Oh never mind, you're just reconstructing from the input 😅
  • j

    James

    04/16/2022, 10:45 PM
    Yeah, I got a bunch of
    Failed to parse URL
    errors locally when trying to do that. A real
    URL
    object was the only way to make that work
  • w

    Walshy | Pages

    04/16/2022, 10:57 PM
    Is https://Google.com/./test.html a valid URL?
  • w

    Walshy | Pages

    04/16/2022, 10:58 PM
    Doesn't feel like it would be
  • k

    kian

    04/16/2022, 10:58 PM
    works for me (not google ofc)
  • k

    kian

    04/16/2022, 10:58 PM
    might be browser behaviour though
  • w

    Walshy | Pages

    04/16/2022, 10:58 PM
    But either way, James just make stuff work
  • k

    kian

    04/16/2022, 10:58 PM
    I get 301'd to something without the
    /./
  • j

    James

    04/16/2022, 10:58 PM
    URL pathname handles that relatively: https://up.jross.me/r8p263w0
  • w

    Walshy | Pages

    04/16/2022, 10:58 PM
    When Greg is here, he can answer the functions stuff better than me.
  • j

    James

    04/16/2022, 10:59 PM
    I'm doing what you told me to do, and moving things to Pages. Shh
  • j

    James

    04/16/2022, 11:28 PM
    I managed to hack around this eventually if anyone else comes by this thread. See https://github.com/cloudflare/wrangler2/issues/370 for the issue, and then https://github.com/Cherry/universe-horse-test/commit/1e1b67cb7ece6306fdffe061c4be80663ded34a2 for my hack which works
  • k

    kian

    04/16/2022, 11:29 PM
    i hate that website
  • j

    James

    04/16/2022, 11:30 PM
    it's become my test site for functions
  • w

    Walshy | Pages

    04/17/2022, 4:22 AM
    I love it!
  • w

    Walshy | Pages

    04/17/2022, 4:22 AM
    (Not just because it's on Pages)
  • g

    Greg Brimble | Cloudflare Pages

    04/17/2022, 5:50 AM
    Once my
    next
    fix goes out, I think we’ll try get everyone using that instead of
    env.ASSETS.fetch
    wherever possible. It’ll still exist (and we’ll try improving it) but it’s tricky to use correctly. You should be doing content negotiation to ensure the incoming request is getting a response that it can handle.
    next
    will automatically pass all of that through for you.
  • g

    Greg Brimble | Cloudflare Pages

    04/17/2022, 5:51 AM
    I’ll try get it out in prod next week.
  • o

    orstavik77

    04/19/2022, 8:32 AM
    I am trying to make a pages project that creates and controls a durable object. I have managed to make a durable object in a separate worker (and then this durable object pops up in the gui in my pages project, so that I can bind a env variable to it). But, I would like to declare the DurableObject class inside the ./functions folder, and then have it created and updated automatically along side the rest of the pages workers. Is this possible? Is there a working github/gitlab project that does this?
  • g

    Greg Brimble | Cloudflare Pages

    04/19/2022, 8:52 AM
    Not currently possible, but something I’ve very much like to see. Stay tuned? (Longer-term)
  • o

    orstavik77

    04/19/2022, 8:54 AM
    Thanks for the quick response:)
  • o

    oldschoolcurry

    04/20/2022, 8:49 AM
    Can anyone help me with this error in a POST function? TypeError: request.json is not a function at onRequestPost export async function onRequestPost(request) { const myPostBody = await request.json(); console.log(myPostBody); return new Response(
    Hello world
    ); }
  • k

    kian

    04/20/2022, 8:56 AM
    Copy code
    js
    export async function onRequestPost({request}) {
        const myPostBody = await request.json();
        console.log(myPostBody);
    
        return new Response(Hello world);
    }
  • k

    kian

    04/20/2022, 8:56 AM
    Try that
1...123124125...392Latest