Astro + Clerk

(cross posting from Clerk) I have an Astro project deployed to Cloudflare Pages. I have a requirement to add authentication to some areas of the site. I've added the Cloudflare adapter and the Clerk integration as per the docs. I was able to get everything up and running as I wanted locally, but when I deploy to Cloudflare, the deployment fails with the error:
Error: Failed to publish your Function. Got error: Uncaught Error: No such module "node:async_hooks".
at _astro-internal_middleware.mjs:4262:33 in createAsyncLocalStorage
at _astro-internal_middleware.mjs:4265:30
Error: Failed to publish your Function. Got error: Uncaught Error: No such module "node:async_hooks".
at _astro-internal_middleware.mjs:4262:33 in createAsyncLocalStorage
at _astro-internal_middleware.mjs:4265:30
I've tried all sorts to get this working such as experimenting with configs (cloudflare, vite, clerk), moving middleware file around, installing wranlger, using a wrangler.toml with node compat I have reconstructed a minimal example that generates the error: https://github.com/danlechambre/minimal-astro-cloudflare-clerk (currently deployed to my Cloudflare account) The project works when deployed, including switching to 'hybrid' and installing the Cloudflare adapter, but the minute I introduce the clerkMiddleware() - it breaks 😢 I feel like this is an 'edge thing' - but not really sure what to look at next? Deploy URL (working before adding Clerk): https://minimal-astro-cloudflare-clerk.pages.dev/ Account ID: 82b1313af677f5eb2d8633b0bbfc8f73
GitHub
GitHub - danlechambre/minimal-astro-cloudflare-clerk: Minimal imple...
Minimal implementation of Astro 'hybrid' rendered app using Cloudflare adapter and Clerk auth - danlechambre/minimal-astro-cloudflare-clerk
1 Reply
DanLeChambre
DanLeChambreOP•2mo ago
I manged to resolve this by revising my wrangler.toml I hadn't realised by creating a toml file I was basically taking over all aspects of configuration, and so I was missing pages_build_output_dir = "dist" from that file
Want results from more Discord servers?
Add your server