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

    nora

    05/08/2023, 8:01 PM
    In short: trying to avoid local browser caching issues of e.g. stylesheets when deploying to a production/staging domain
  • s

    Skye

    05/08/2023, 8:04 PM
    There's an env variable of
    CF_PAGES_COMMIT_SHA
    ?
  • n

    nora

    05/08/2023, 8:08 PM
    Thanks!
  • n

    nora

    05/08/2023, 8:09 PM
    Didn't see it because it's not listed @ https://developers.cloudflare.com/pages/platform/functions/api-reference/#envwithfetch hehe
  • w

    Walshy | Pages

    05/08/2023, 8:13 PM
    it's here:
  • w

    Waldo

    05/09/2023, 5:14 PM
    I can't seem to figure out a way to list the names of a bunch of .html files from a specific folder in my Pages project from a Pages function. Any idea if something like this is doable at all ?
  • j

    James

    05/09/2023, 5:16 PM
    Not possible as far as I know. You can
    env.ASSETS.fetch
    a specific file, but no arbitrary listing.
  • w

    Waldo

    05/09/2023, 5:18 PM
    Got it, thanks!
  • b

    By_Moglii

    05/09/2023, 8:33 PM
    guys i need help how i can delete my website ?
  • d

    Dani Foldi

    05/09/2023, 8:34 PM
    Already answered in #812577823599755274
  • I ve seen this error mentioned there
    n

    Nipsuli

    05/10/2023, 5:52 AM
    I've seen this error mentioned there earlier as well. I'm looking for best ways to debug and profile to see which part of our application causes the
    Error: Failed to publish your Function. Got error: Error: Script startup exceeded CPU time limit
    our main app is Remix app. Like what all happens during the startup? Like could I just achieve same setup with some local test? I already tried profiling importing the compiled functions handler. Is this the correct way? Would make me sad if we'd have to migrate our application away from the best platform I know of 😭
    e
    • 2
    • 3
  • b

    BryceWray

    05/11/2023, 2:54 AM
    Am currently trying
    _middleware.js
    stuff for the first time with CF Pages, in an attempt to use it instead of an existing CF Worker. Works perfectly on the
    pages.dev
    version — but, on the custom-domain version from that
    pages.dev
    , only the HTML files are affected even though it’s for all routes and files. Is there something special I have to do in the domain’s DNS, or elsewhere, to make the middleware work properly on the custom domain, too? (And I did remove the custom domain’s routes from the Worker for the test, so the Worker shouldn’t have been interfering.) The
    pages.dev
    domain = static-site-2to.pages.dev The custom domain = brycewray.com **Note**: I have had to add the custom domain routes back to the Worker and take the
    _middleware.js
    file out of the project in order to regain the previous functionality, until I can learn why the middleware file doesn’t work on the custom domain. Let me know (during U.S. daytime hours, please) if you want me to restore the test setup.
  • s

    sideshot

    05/13/2023, 11:23 PM
    I created my first svelteKit site, and followed the directions to use the cf adapter then push to git. It is failing deployment because of the _route.js is more than 100 chars. When I look in the file it generates the exclude for each file in my static/assets/images folder. How can I fix this without manually adjusting the _routes.js file? 19:14:19.497 ✨ Upload complete! 19:14:21.111 Success: Assets published! 19:14:22.206 Error: Failed to publish your Function. Got error: Error 8000057: Rule (%s) in
    routes.json
    is over the 100 character limit. Refer to https://cfl.re/3FsE4aF.
  • w

    Walshy | Pages

    05/14/2023, 12:00 AM
    I'd report this to SvelteKit. There's not much you can do since they generate it
  • s

    sideshot

    05/14/2023, 2:45 AM
    I'm not sure that error is a result of the _routes.json file that was in the cloudflare folder of the npm build from the svelte export. I modified the file directly and even deleted it and I'm still getting that error.
  • w

    Walshy | Pages

    05/14/2023, 2:46 AM
    it's related to the _routes.json in the output directory
  • w

    Walshy | Pages

    05/14/2023, 2:46 AM
    whatever the output dir is
  • w

    Walshy | Pages

    05/14/2023, 2:46 AM
    how were you deleting it? After running the svelte build?
  • s

    sideshot

    05/14/2023, 2:55 AM
    So i just tried to push it using wrangler. Had it create a new project. Went perfect no problems.
  • s

    sideshot

    05/14/2023, 2:55 AM
    So it must be something with coming from the git repo.
  • s

    sideshot

    05/14/2023, 3:06 AM
    actually, I see what happened. When I fixed the _routes file, then went back to the initial "Deploy a site from your account > Git". When it would try the initial deployment, and fail. I never left this screen (because it would give a pop-up warning to not leave with incomplete deployment.). I would click the "retry". I now see it kept retrying the same commit version, instead of the newest one. The build that was also failing, no longer is failing because it auto deployed to the fixed version. This is what caused my confusion. https://developers.cloudflare.com/pages/framework-guides/deploy-a-svelte-site/#sveltekit-cloudflare-configuration Showed the config to be
    adapter: adapter(),
    I found this link with the fix https://kit.svelte.dev/docs/adapter-cloudflare#usage
    Copy code
    adapter: adapter({
                // See below for an explanation of these options
                routes: {
                    include: ['/api/*'],
                    exclude: []
                }
            })
    Hope this helps others.
  • e

    Evan

    05/18/2023, 10:14 AM
    Can I just make sure that I can direct upload a pages site with functions? (planning on using the nextjs adapter)
  • w

    Walshy | Pages

    05/18/2023, 10:16 AM
    You can. Just not through the dashboard drag and drop
  • m

    modichutiyathaaurhai

    05/18/2023, 11:09 AM
    Can pages functions be used with modules syntax? Can a normal worker have routes and middlewares with directories? Are docs outdated for pages functions & more using service workers syntax?
  • w

    Walshy | Pages

    05/18/2023, 11:13 AM
    > Can pages functions be used with modules syntax? If you wanted yep - > Can a normal worker have routes and middlewares with directories? With a routing lib yep, maybe checkout Hono - > Are docs outdated for pages functions & more using service workers syntax? Nope. The recommended way is still file based routing for Functions. But if you want to use the more standard worker format you're free to do so!
  • e

    Evan

    05/18/2023, 12:16 PM
    ty, it's just because of it being a private gitlab
  • m

    modichutiyathaaurhai

    05/18/2023, 12:23 PM
    Thank you I am a beginner
  • m

    modichutiyathaaurhai

    05/18/2023, 12:23 PM
    Are pages invoked in / even if there is no index.js in functions directory? If so how to only invoke functions on /users/* directory and exclude everything else (excluding /, /static etc). How to have a different route on /users/[user]/[number] than /users/[user] in pages functions?(context- /users/[user] makes api requests with unique jwt to user, parses json and returns html with links to /users/[user]/[id] and /users/[user]/[id] makes same api requests again and makes another api request with data from that resulting in a url and 0(redirects to that url? If this approach is not good then suggest any others, one maybe that another route with /redirect?users=[users]&id=[number] will that work and how to do it?
  • j

    jorjik

    05/18/2023, 6:56 PM
    Copy code
    Compiling worker to "/var/folders/fr/_pqhdcfs1r701w_r80w78tw80000gn/T/functionsWorker-0.899414644570004.mjs"...
    ▲ [WARNING] No routes found when building Functions directory: ./functions - skipping
    
    
    No functions. Shimming...
     ⛅️ wrangler 3.0.0
    guys I can't understand why
    wrangler pages dev _site
    can't see the functions folder
  • s

    Skye

    05/18/2023, 6:57 PM
    It can see it, but there's not any valid functions inside it
1...386387388...392Latest