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

    Dude

    01/10/2022, 1:45 AM
    I use Hugo. Hugo exports its static site into a "public" directory. So in my project's root folder, i have a /public and a /functions subfolders.
  • d

    Dude

    01/10/2022, 1:47 AM
    yes. my
    functions
    folder is inside my project's root folder where I run the command. but it doesn't seem to serve the function
  • d

    DevNoob

    01/10/2022, 4:00 AM
    Anyone could increase function requests limit? I've filled up the form but no joy 🙂
  • e

    Erwin

    01/10/2022, 5:39 AM
    Someone should have a look at that and make the change @User..
  • g

    Greg Brimble | Cloudflare Pages

    01/10/2022, 11:02 AM
    Do you have a repo I can look at?
  • b

    bsam75

    01/10/2022, 5:26 PM
    Im having issues trying to get wrangler pages dev to server my local directory. The directory only contains a functions fodler with a [[slug]].js to handle all routes. The command im running is:
    npx wrangler@beta pages dev ./ --proxy 8000 --kv SECOND_KV_NAMESPACE
    and my server started with from the project root directory:
    python3 -m http.server 8000
    Im getting a 404 on all pages, is it supposed to work on this setup?
  • g

    Greg Brimble | Cloudflare Pages

    01/10/2022, 7:06 PM
    You likely don’t need the proxy pieces there.
  • g

    Greg Brimble | Cloudflare Pages

    01/10/2022, 7:07 PM
    If you’re just trying to serve a static folder, you can just
    npx wrangler pages dev ./that-folder
  • g

    Greg Brimble | Cloudflare Pages

    01/10/2022, 7:07 PM
    No need for the Python command
  • b

    bsam75

    01/10/2022, 7:13 PM
    @User Thanks, but I still get a 404. Calling this from the root of my project.
    npx wrangler@beta pages dev ./ --kv KV_NAMESPACE_NAME
  • g

    Greg Brimble | Cloudflare Pages

    01/10/2022, 7:30 PM
    Do you have a repo you can share?
  • b

    bsam75

    01/10/2022, 7:33 PM
    Yea, sure can. Should I just DM you?
  • g

    Greg Brimble | Cloudflare Pages

    01/10/2022, 7:35 PM
    Can do!
  • d

    Dude

    01/11/2022, 6:43 AM
    Hi @User , after checking the compiled worker
    functionsWorker.js
    created by the pages dev command, i found that the routePath was not properly escaped,.?
  • d

    Dude

    01/11/2022, 6:44 AM
    this is the structure of my functions directory: - functions/api/collection - functions/api/tokens but routes.routePath in the compiled
    functionsWorker.js
    were
    "/apicollection"
    and
    "/api    okens"
    ps. i'm using Windows
  • g

    Greg Brimble | Cloudflare Pages

    01/11/2022, 9:23 AM
    Known issue: https://github.com/cloudflare/wrangler2/issues/51 https://github.com/cloudflare/wrangler2/issues/50 https://github.com/cloudflare/wrangler2/issues/92
  • j

    Jaren

    01/11/2022, 3:39 PM
    How do I view logs for functions? I'm getting an error saying my worker threw an exception and to check logs, but i'm not seeing anywhere to view them
  • o

    oliverjam

    01/11/2022, 3:45 PM
    You can't right now. I think I've seen recommendations to send logs to a 3rd party service like Sentry (if you can't reproduce the error locally)
  • g

    Greg Brimble | Cloudflare Pages

    01/11/2022, 5:32 PM
    npx wrangler@beta pages dev --help
    if you want to try reproducing locally.
  • g

    Greg Brimble | Cloudflare Pages

    01/11/2022, 5:32 PM
    We’ll get production logs in place for GA
  • w

    Warlando

    01/12/2022, 9:22 AM
    Hi there, anyone could help me on how to add environment variables in functions on local development?
  • w

    Warlando

    01/12/2022, 9:23 AM
    I've tried the .toml file with no success
  • g

    Greg Brimble | Cloudflare Pages

    01/12/2022, 9:29 AM
    npx wrangler pages dev ./static_assets_dir --binding ENV_VAR_NAME=VALUE
  • w

    Warlando

    01/12/2022, 9:30 AM
    That's great! but what if I've a long list? is there a way to point to a
    .env
    file or something similar?
  • w

    Warlando

    01/12/2022, 9:32 AM
    I could definitely build my way around it but wonder if there's a cleaner solution like when you pass the
    .toml
    config file with the
    --config
    flag
  • w

    Warlando

    01/12/2022, 9:45 AM
    for anyone who might be looking for a cleaner way to get your long list of env variables available on local development this was the best solution I've found:
    npx wrangler pages dev --binding $(cat .env) -- npm run dev
  • w

    Warlando

    01/12/2022, 9:46 AM
    this way you can still store all your env vars under your
    .env
    file
  • g

    Greg Brimble | Cloudflare Pages

    01/12/2022, 10:18 AM
    Not currently. There are some issues up on the wrangler repo tracking this, but they haven’t yet been implemented.
  • b

    bsam75

    01/12/2022, 9:24 PM
    I have a question about _worker.js (pages->functions->_worker.js ) does it work on
    wrangler pages dev
    environment? I have not gotten it to work successfully.
  • g

    Greg Brimble | Cloudflare Pages

    01/13/2022, 12:13 AM
    _worker.js
    should be placed in your static assets folder for it to be picked up
1...565758...392Latest