Possible to set node_compat on Pages Functions?

Hello,

I’m currently building a static Next.js site on pages that needs just a couple of supporting backend bits. I’d prefer not to make the whole site dynamic as at this point it would require me to completely overhaul the data access (which is reading frontmatter+markdown from static files on the filesystem at build time).

One of the functions is using the Square Payments API which requires some node.js APIs. When I try to create it as a function, the build errors out with:

The package “crypto” wasn’t found on the file system but is built into node.
Add “node_compat = true” to your wrangler.toml file to enable Node compatibility.

However, it doesn’t seem like Functions respects a wrangler.toml that exists in the repo.

Is there a way to accomplish what I’m trying to accomplish within the Cloudflare Pages product, or do I need to bite the bullet and do a complete separate setup on Workers to handle this one function?

Thanks!

Unfortunately you can’t use node_compat with Functions today, outside of bundling your own worker entirely.

I’d recommend you use Workers directly for this.

Disappointing but not unexpected.

Any good place to put in a feature request for this?

The wrangler2 repo at GitHub - cloudflare/wrangler2: ⛅️ The CLI for Cloudflare Workers® would probably be the best place. There’s likely already an issue tracking this.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.