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

    HardAtWork

    01/05/2022, 1:16 PM
    Not yet, but
  • c

    Cоlе

    01/05/2022, 8:36 PM
    https://github.com/cloudflare/wrangler2/issues/92 you're on windows?
  • l

    LucasW

    01/05/2022, 11:15 PM
    Can we expect Pages Functions to go out of beta soon?
  • l

    LucasW

    01/05/2022, 11:15 PM
    How easy it is to increase the current limit of 100,000 requests? And how much can we increase it?
  • j

    Josh

    01/05/2022, 11:21 PM
    Hey, there is a form in the pins to get it increased 👍🏼
  • j

    Josh

    01/05/2022, 11:21 PM
    I’d like to think around 3-4 months but CF don’t release public timelines
  • l

    LucasW

    01/05/2022, 11:22 PM
    Thanks for the informations!
  • c

    Cоlе

    01/05/2022, 11:31 PM
    Has anyone had any success using a
    _headers
    file? I tried putting it in the root and
    /functions
    but no dice.
    Copy code
    /*
      Access-Control-Allow-Origin: *
  • c

    Cоlе

    01/05/2022, 11:32 PM
    I'm testing in wrangler, but I haven't been able to get it working in production either
  • g

    Greg Brimble | Cloudflare Pages

    01/05/2022, 11:47 PM
    Needs to be in your build output directory (with your static assets) 🙂
  • c

    Cоlе

    01/05/2022, 11:56 PM
    ah ok, thanks
  • l

    Leander

    01/06/2022, 5:13 AM
    Did you manage to get it working? For me it's working for static assets but not functions.
  • c

    Cоlе

    01/06/2022, 5:17 AM
    I haven't had a chance; I misspelled
    _headers
    three times, then decided that maybe it was time to take a break
  • c

    Cоlе

    01/06/2022, 5:17 AM
    that might be intentional? if it's in your build folder, that would make sense
  • l

    Leander

    01/06/2022, 5:18 AM
    Yeah, might be intentional.
  • c

    Cоlе

    01/06/2022, 5:19 AM
    you can always fall back on a
    Copy code
    ts
    let headers = { 'content-type': 'application/json;charset=utf8', "Access-Control-Allow-Origin": "*" };
    return new Response(body, { headers, status });
  • c

    Cоlе

    01/06/2022, 5:21 AM
    to make it real easy, you could implement that as a piece of middleware that runs
    const res = await next()
    then does the above to it ^
  • m

    martior

    01/06/2022, 6:10 PM
    not sure if this should be in wrangler or here, but when I run
    npx wrangler pages dev -- npm start
    to serve a tailwind react-app and I open port 8788 in the browser wrangler crashes with "TypeError: Web Socket request did not return status 101 Switching Protocols response with Web Socket" I can serve the function on :8788/api and also static assets from react and the react app works as normal on port :3000
  • j

    Jaren

    01/07/2022, 3:26 PM
    I'm trying to setup a function that rewrites all
    /profile/:whatever
    endpoints to
    /profile/[profile].html
    (generated by next.js), but i'm getting an http error 406 with this code. I've tried changing the pathname to
    /profiles/[profile].html
    , but that just caused a redirect loop back to
    /profiles/[profile]
  • p

    PReimers

    01/07/2022, 3:56 PM
    Hey 👋 I hope I'm in the right cannel here. I'm working on a small website (build with Vue JS 3) that requires some "API calls" to a few functions. Now I'm trying to optimize my (messy/PoC) code a bit and reduce duplicate code. I'm using a
    config.json
    for some basic configuration parameter in the frontend. Is it possible to use this file in a function too (using an
    require
    or
    import
    statement)?
  • r

    rkusa

    01/07/2022, 4:17 PM
    Copy code
    ts
    import config from "../config.json";
    and
    "resolveJsonModule": true
    in your
    tsconfig.json
    (if you use TS) should be all that's necessary
  • p

    PReimers

    01/07/2022, 4:17 PM
    Great, thank you 😊
  • p

    PReimers

    01/07/2022, 4:18 PM
    I was just concerned about if it would work with the "functions" 🙈 -> Testing it always takes quite long 😐
  • r

    rkusa

    01/07/2022, 4:23 PM
    Isn't Next.js creating a
    /profile/[profile]/index.html
    (and not a
    /profile/[profile].html
    )? If so, the following might work:
    Copy code
    ts
      env.ASSETS.fetch(
        new Request(
          new URL("/profile/[profile]/", request.url).toString(),
          request
        )
      )
    The trailing
    /
    was important IIRC. Also, your message has a mix of singular and plural `profile`/`profiles` - which could also the underlying issue.
  • s

    sandeepsihari

    01/07/2022, 7:28 PM
    Yes on windows 👍
  • c

    Cоlе

    01/07/2022, 7:41 PM
    I'm trying to raise awareness for this bug 😮‍💨 seems like it could be similar to a previous Windows related issue with wrangler: https://discord.com/channels/595317990191398933/799437470004412476/911936976209457162
  • j

    Jaren

    01/08/2022, 3:03 AM
    It's definitely making a /profiles/[profile].html. It's meant to be plural, that was a mistake when writing the message
  • j

    Jaren

    01/08/2022, 3:03 AM
    in fact without the function, going to /profiles/[profile] goes to the right page
  • c

    Cоlе

    01/08/2022, 3:25 AM
    I tried using cache (from workers) in functions, but I'm getting
    [pages:err] SyntaxError: Unexpected reserved word
    in wrangler. Is cache not supported?
  • s

    steranevdy

    01/08/2022, 4:27 AM
    what's the difference between env.ASSETS.fetch vs the normal fetch?
1...545556...392Latest