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

    Isaac McFadyen | YYZ01

    02/20/2022, 4:31 PM
    Anyone else know?
  • e

    Erisa | Support Engineer

    02/20/2022, 4:33 PM
    not available yet, no way to set and it defaults to the old value sadly :(
  • e

    Erisa | Support Engineer

    02/20/2022, 4:34 PM
  • e

    Erisa | Support Engineer

    02/20/2022, 4:34 PM
    in the same place greg notes in the meantime you can try using https://github.com/ssttevee/js-cfw-formdata-polyfill#readme
  • e

    Erisa | Support Engineer

    02/20/2022, 4:35 PM
    (https://discord.com/channels/595317990191398933/910978223968518144/918854490738790541)
  • r

    RaifY

    02/20/2022, 4:37 PM
    Wow, I spent a afternoon for finding polyfill like this, thanks for your help!
  • e

    Erisa | Support Engineer

    02/20/2022, 4:38 PM
    no prob!
  • e

    Erisa | Support Engineer

    02/20/2022, 4:38 PM
    hopefully we can use the native File behaviour soon!
  • g

    Greg Brimble | Cloudflare Pages

    02/20/2022, 4:39 PM
    💯 . I want to personally use it. Definitely high on the list.
  • e

    Erisa | Support Engineer

    02/20/2022, 4:40 PM
    I'm surprised Walshy isn't demanding it internally 😛
  • g

    Greg Brimble | Cloudflare Pages

    02/20/2022, 4:41 PM
    We've kept him busy with other stuff 😛
  • r

    RaifY

    02/20/2022, 5:06 PM
    it seems
    instanceof File
    not work after importing the polyfill. I'm trying to patch the prototype of built-in File class
  • k

    Kedas

    02/20/2022, 5:29 PM
    is there any way to debug functions after they've been published? I have this code
    Copy code
    js
    let n = await next()
    if(!n.headers.get("Content-Type") || !n.headers.get("Content-Type").includes("text/html")) {
        return n
    }
    and it's been giving me an error, but the stacktrace doesn't give me anything useful and it only gives me an error on some of the requests, seemingly at random. alternatively, is there a way to exclude a static file from being handled by a wildcard function?
  • g

    Greg Brimble | Cloudflare Pages

    02/20/2022, 5:44 PM
    This is failing because
    n.headers.get("Content-Type")
    is null, so you can't call
    .includes("text/html")
    on it. Try this instead:
    if(!n.headers.get("Content-Type") || !n.headers.get("Content-Type")?.includes("text/html")) {
  • g

    Greg Brimble | Cloudflare Pages

    02/20/2022, 5:45 PM
    Debugging Functions in prod is unfortunately not very easy at the moment. We're working on improving that before we come out of beta.
  • k

    Kedas

    02/20/2022, 5:45 PM
    wouldn't that be prevented by
    !n.headers.get("Content-Type")
    ?
  • g

    Greg Brimble | Cloudflare Pages

    02/20/2022, 5:48 PM
    Hmm, yeah, you're right, it should be.
  • g

    Greg Brimble | Cloudflare Pages

    02/20/2022, 5:48 PM
    Are you using
    .includes
    anywhere else in your Functions?
  • k

    Kedas

    02/20/2022, 5:52 PM
    oh yeah, i forgot I had the same code in another function but didn't add the condition that checks for it being null. thank you :) I'm still a little confused about why some requests to the same endpoint would fail and others wouldn't, and why it worked flawlessly with wrangler - could this be a bug?
  • k

    Kedas

    02/20/2022, 6:07 PM
    also, how would proxying with wrangler work, i tried something like
    npx wrangler pages dev --proxy 3000 ./build -- npm run dev
    but it just serves the build folder and doesn't even run the command
  • g

    Greg Brimble | Cloudflare Pages

    02/20/2022, 7:34 PM
    You either pass the build output directory, or a proxy command. You don't need both. Preference for the build output directory, if you can.
  • k

    Kedas

    02/20/2022, 7:35 PM
    Issue is that I can't do only proxy for some reason
  • g

    Greg Brimble | Cloudflare Pages

    02/20/2022, 7:35 PM
    We're trying to make wrangler a faithful simulation of what happens in production, but it's not quite perfect yet, so you might see some discrepancies. If you do, please file an issue in the wrangler2 repo with with minimal reproduction steps.
  • g

    Greg Brimble | Cloudflare Pages

    02/20/2022, 7:36 PM
    How so? We recently fixed a bug with this, so try grabbing the latest
    wrangler@alpha
    .
  • k

    Kedas

    02/20/2022, 7:36 PM
    Ah alright, I'll try that
  • l

    Larry

    02/21/2022, 12:06 AM
    You should be able to do this with
    env.ASSETS.fetch('your/file.json')
  • k

    Kieran Huggins

    02/21/2022, 12:07 AM
    Thanks I’ll give that a shot - I went with regular fetch and that worked in the meantime
  • k

    Kieran Huggins

    02/21/2022, 12:23 AM
    looks like the arg has to be the full URL, but it does seem to cut the network req. Thanks!
  • l

    Larry

    02/21/2022, 1:01 AM
    This probably goes without saying, but you should probably prefix your local file with something like
    new URL(request.url).origin + '/your/file.json'
  • g

    Greg Brimble | Cloudflare Pages

    02/21/2022, 1:15 AM
    Some more info: https://github.com/cloudflare/wrangler2/issues/165#issuecomment-1010849903
1...798081...392Latest