Using connect() API in Pages
Hi team. I have a Pages function that talks directly to a Postgres DB using the new connect() API (detailed here: https://developers.cloudflare.com/workers/databases/connect-to-postgres).
The code works fine in a Worker and also when running Pages locally. But when trying to deploy to CF, I get node compatibility errors. I have the
nodejs-compat
flag set. What am I missing?
5 Replies
Yes, I'm using the latest v8.11.0
It works locally with the deprecated
--node-compat
flag. I'm not having any luck setting the nodejs-compat
compatibility-flag. It doesn't seem to have an effect.
Is node compatibility supported in Pages functions?It requires the wrangler node compat flag not the compatibility date node compat flag
(yes it's confusing )
Publish/UI doesn't have
--node-compat
If I'm understanding correctly, that means pg isn't supported in Pages yet since the
--node-compat
flag isn't available? It will only work in a worker?You could do the node pollyfills yourself
but natively with wrangler, yes
hopefully it'll just work soon with the native node compat
Okay that's not necessarily so bad. I can either add polyfills for the pages functions or bind a worker.
Do you have any guidance or docs on hand for adding polyfills in pages?