How to Enable Node Compatibility Mode for CF Pages Dployment (with Astro endpoint)?
Do I just create and format a wrangler.toml file as if for CF Workers, or is enabling node compatibility mode different for a Pages project with an Astro endpoint? Thanks.
3 Replies
It basically works the same as Workers as far as I am aware.
If you have a wrangler.toml or .jsonc file you add it to that file. If not, you can add the compatibility flag in the dashboard as well.
Since compatibility dates and flags work basically the same in workers and pages this page from the Workers docs pretty much applies for Pages too: https://developers.cloudflare.com/workers/configuration/compatibility-flags/
Cloudflare Docs
Compatibility flags
Opt into a specific features of the Workers runtime for your Workers project.
Would this be sufficient?
If you do not have a wrangler.toml file yet, you can run
wrangler pages download config
.
This command will download your existing configuration from the dashboard and create a configuration file from it.
See the documentation about it here: https://developers.cloudflare.com/pages/functions/wrangler-configuration/#projects-without-existing-wrangler-file
Make sure that a pages_build_output_dir
field is present in the generated file and then add your compatibility flag like so:
compatibility_flags = ["nodejs_compat"]
Please note however that if you're using a Wrangler configuration file, you must treat your file as the source of truth for your Pages project configuration.Cloudflare Docs
Configuration
Pages Functions can be configured two ways, either via the Cloudflare dashboard or the Wrangler configuration file, a file used to customize the development and deployment setup for Workers and Pages Functions.