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

    James

    04/16/2022, 10:12 PM
    Happy to share code if it helps, just wondering if anyone else sees that and immediately goes "aha, I know what that is"
  • i

    Isaac McFadyen | YYZ01

    04/16/2022, 10:13 PM
    How are you doing
    await next()
    if it's on a different route?
  • i

    Isaac McFadyen | YYZ01

    04/16/2022, 10:14 PM
    IIRC that only gets the asset that's on the same route as you did the request on, and you need to use env.ASSETS.fetch() otherwise.
  • j

    James

    04/16/2022, 10:14 PM
    Copy code
    const lookupFile = new URL(request.url);
    lookupFile.pathname = './test.html';
    const asset = await next(lookupFile);
  • j

    James

    04/16/2022, 10:14 PM
    oh I can't do that?
  • i

    Isaac McFadyen | YYZ01

    04/16/2022, 10:14 PM
    Oh. I'd try actually looking it up in env.ASSETS.fetch yourself.
  • i

    Isaac McFadyen | YYZ01

    04/16/2022, 10:15 PM
    Although Walshy might have another option πŸ™‚
  • j

    James

    04/16/2022, 10:16 PM
    Same behaviour - 301s to whatever asset I fetch. Weird
  • w

    Walshy | Pages

    04/16/2022, 10:16 PM
    You can do
    next(string)
    though not sure the behaviour compared the ASSETS.fetch
  • i

    Isaac McFadyen | YYZ01

    04/16/2022, 10:17 PM
    Are you returning the response from next() without any modifications?
  • j

    James

    04/16/2022, 10:18 PM
    Yep right now I'm checking if there's a query param
    q
    , if so, trying to request a new asset, and then returning it, otherwise just passing through
    next()
    . I want to change the html file I serve without altering the URL
  • i

    Isaac McFadyen | YYZ01

    04/16/2022, 10:18 PM
    Huh... I have no clue then, sorry πŸ˜…
  • j

    James

    04/16/2022, 10:19 PM
    I think I'm missing something obvious, but the docs for how
    next
    works aren't super verbose yet
  • w

    Walshy | Pages

    04/16/2022, 10:21 PM
    well
  • w

    Walshy | Pages

    04/16/2022, 10:22 PM
    we redirect files to without their extensions
  • w

    Walshy | Pages

    04/16/2022, 10:22 PM
    I wouldn't expect that on assets.fetch but err
  • w

    Walshy | Pages

    04/16/2022, 10:22 PM
    what happens if you do just /test
  • j

    James

    04/16/2022, 10:22 PM
    oh geez, lemme check
  • j

    James

    04/16/2022, 10:23 PM
    yeah that worked perfectly. Sounds like a bug πŸ˜…
  • j

    James

    04/16/2022, 10:23 PM
    Thanks @Walshy | Pages πŸ™‚ Not sure if that's a runtime bug, or wrangler specific - want me to file or you got it?
  • w

    Walshy | Pages

    04/16/2022, 10:23 PM
    check if the 301 happens in prod and if it doesn't file a bug
  • j

    James

    04/16/2022, 10:27 PM
    I always find the most obscure bugs, I'm sorry πŸ˜…
  • k

    kian

    04/16/2022, 10:28 PM
    Couldn't break the demo so you broke Functions
  • k

    kian

    04/16/2022, 10:28 PM
    You can't be left unsupervised
  • j

    James

    04/16/2022, 10:34 PM
    Thankfully fast builds are making testing this nice and quick. Though logs would be quicker πŸ˜„
  • k

    kian

    04/16/2022, 10:36 PM
  • k

    kian

    04/16/2022, 10:36 PM
    put 'logs access' into that contract
  • j

    James

    04/16/2022, 10:42 PM
    https://github.com/Cherry/universe-horse-test works perfectly locally with
    npx wrangler@beta pages dev ./public
    , but https://universe-horse-test.pages.dev/?test 406's in prod. πŸ€”
  • j

    James

    04/16/2022, 10:42 PM
    406 occurs with both
    ./test.html
    and
    ./test
    . Hmm
  • i

    Isaac McFadyen | YYZ01

    04/16/2022, 10:43 PM
    The only thing I can think of there is that you're reconstructing a
    new URL
    twice.
1...122123124...392Latest