Shared logic between NextJS app or duplicate the logic?

I naively thought I could share the logic from my nextjs app with my cloudflare workers but the environment variables is causing quite a bit of issues. Even when polyfilling with import * as process from 'node:process'; , whenever I use process.env, the nextjs app doesn't understand "node:process". Is it common to simply duplicate the logic for the cloudflare worker? Even my database calls requires a separate env and it's a bit too integrated. Is it common for folks to duplicate their code logic for CF workers or are people commonly able to reuse logic from their app? Is it common to declare something like globalThis.process = process (imported from node:process) when using cloudflare workers for nextjs and cloudflare worker compatability? I'm currently getting this error when I include import * as process from 'node:process'; in my nextjs app.
Module build failed: UnhandledSchemeError: Reading from "node:process" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
Import trace for requested module:
node:process
Module build failed: UnhandledSchemeError: Reading from "node:process" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
Import trace for requested module:
node:process
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server