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

    Ed

    12/08/2021, 11:15 AM
    Hi, I'm trying to see if I can get NextAuth to work in a pages/functions context. There appears to be a lot of overlap in the way the Next api folder and the Cloudflare functions folder can work--the same useSWR hook can invoke from the api folder locally and the functions folder remotely. However, NextAuth is dependent on a number of env variables, notably NEXTAUTH_URL (https://next-auth.js.org/configuration/options) and I'm not sure how I might scope that one in particular from a kv store or other location since it seems to be read in the background. There's another issue related to getting that variable to match the hash of preview deployments but that seems marginally less blocking.
  • a

    andheller

    12/08/2021, 7:28 PM
    13:06:02.836 > Using @sveltejs/adapter-cloudflare 13:06:02.873 ✔ done 13:06:02.899 Finished 13:06:03.018 Compiling worker to "/opt/pages/functions/user-worker.js" 13:06:03.027 Finished in 31ms. 13:06:03.036 Validating asset output directory 13:06:04.390 Deploying your site to Cloudflare's global network... 13:06:13.230 Failed: an internal error occurred I'm getting a Failed: an internal error occurred at the end of deploying a sveltekit site with the cloudflare adapter. It was working when it was static. Is there a way to see more logs on the build?
  • w

    Walshy | Pages

    12/08/2021, 7:28 PM
    Can you please validate that your build output folder is definitely correct?
  • a

    andheller

    12/08/2021, 7:31 PM
    It was set to build. I changed it to cloudflare and will try to rebuild now
  • a

    andheller

    12/08/2021, 7:44 PM
    Thank you for your help! .svelte-kit/cloudflare worked! Is there any way to force the build initialization to only use Node and NPM and not Swift, Ruby, PHP, and Python
  • e

    Erwin

    12/08/2021, 8:23 PM
    Not yet, we will have some good news about Pages build initialisation soon soon though 😁
  • c

    Cоlе

    12/08/2021, 8:52 PM
    is anyone else having issues with separate functions? I pushed a small change today, and all of a sudden all of my routes are 404-ing, except for
    functions/index.ts
    and
    functions/*/index.ts
    . starting to wonder if I'm going insane
  • c

    Cоlе

    12/08/2021, 8:53 PM
    functions/*/*/index.ts
    also isn't working, and parameterized files aren't loading either (unless I move/renamed them to one of the aforementioned paths)
  • c

    Cоlе

    12/08/2021, 8:56 PM
    functions/_middleware.ts
    and
    functions/*/_middleware.ts
    work as well.
    functions/*/*/_middleware.ts
    works when published, but not through wrangler dev 😭
  • c

    Cоlе

    12/08/2021, 9:34 PM
    yea this is pretty wack. I have an old deployment running an earlier commit, works fine. If I grab that same commit and run it again with wrangler dev, it's broken 😦
  • c

    Cоlе

    12/08/2021, 9:49 PM
    nvm seems to have just fixed itself. thank you cloudflare, very cool
  • a

    Adam Reed

    12/08/2021, 10:08 PM
    Is there any way to get into your Page Functions for Debugging?
  • a

    Adam Reed

    12/08/2021, 10:08 PM
    Remotely?
  • a

    Adam Reed

    12/08/2021, 10:08 PM
    Like there is with Workers?
  • e

    Erwin

    12/08/2021, 10:11 PM
    There was an incident earlier today that was interrupting Pages builds as well.. that may have been the issue.. 😦
  • e

    Erwin

    12/08/2021, 10:13 PM
    Debugging is still very much a work in progress, but I find the
    npx wrangler@beta pages dev
    works well for pretty much anything except Durable Objects.. We are still working out how to best support the different Durable Object scenarios.. I hope we'll have something more concrete in a week or two..
  • a

    Adam Reed

    12/08/2021, 10:13 PM
    I meant server-side, like when you debug a worker and can watch the log output in the web.
  • a

    Adam Reed

    12/08/2021, 10:13 PM
    I suppose I'll have to learn to use Wrangler.
  • a

    Adam Reed

    12/08/2021, 10:14 PM
    I've just been building from Git as I'm building in Blazor, so there wasn't much use from Wrangler for me that I could see.
  • e

    Erwin

    12/08/2021, 10:36 PM
    You don't have to install anything locally..
    npx
    will just execute the package
  • e

    Erwin

    12/08/2021, 10:37 PM
    But yeah.. like I said.. debugging is still very much a work in progress 🙂
  • a

    Adam Reed

    12/08/2021, 10:37 PM
    Sorry, it's a new dev env for me, I am used to working in a VS/.NET/Azure env. I'll have to look into it, thank you!
  • e

    Erwin

    12/08/2021, 10:38 PM
    I can totally sympathise! Leave us all the feedback you can, we absolutely greatly appreciate it 🙂
  • a

    Adam Reed

    12/08/2021, 10:39 PM
    Just to keep myself on the same page, I'm building out a Middleware that logs all my requests to Azure Application Insights so I can stick with some familliar tools 😄
  • a

    Adam Reed

    12/08/2021, 10:39 PM
    Thanks to this post I found here 😄 https://www.meziantou.net/tracking-cloudflare-requests-using-application-insights.htm
  • s

    Subh

    12/09/2021, 11:07 AM
    If I need to run the functions locally, how do I? This is not clear in https://developers.cloudflare.com/pages/platform/functions#develop-and-preview-locally
    npx wrangler pages dev
    ?
  • c

    chrisjmccreadie

    12/09/2021, 11:09 AM
    wrangler pages dev functions
  • g

    geelen

    12/09/2021, 11:14 AM
    npx wrangler@beta pages dev
  • g

    geelen

    12/09/2021, 11:14 AM
    or leave off the
    @beta
    if you've already done
    npm install --save-dev wrangler@beta
  • s

    Subh

    12/09/2021, 11:15 AM
    npx wrangler pages dev functions
    Serving functions... Sleeping 5 seconds to allow proxy process to start before attempting to automatically determine port... To skip, specify the proxy port with --proxy. [proxy]: INFO: Accepting connections at http://localhost:3000 Automatically determined the proxy port to be 3000. Compiling worker to "/var/folders/bs/bl0zkc1x4pxd1l3zmfst7b5m0000gn/T/functionsWorker.js" Finished in 61ms. [HPM] Proxy created: / -> http://127.0.0.1:59394 [HPM] Proxy created: / -> http://127.0.0.1:3000 Serving at http://127.0.0.1:8788/
1...343536...392Latest