I’m trying to follow the instructions as per here: MailChannels · Cloudflare Pages docs
It shows that you need to add some info to the personalizations object, in particular this one:
"dkim_private_key": context.env.DKIM_PRIVATE_KEY
Whenever I do that, the deployment fails with this:
17:10:49.186 ✨ Compiled Worker successfully
17:10:49.217 Validating asset output directory
17:10:49.850 Deploying your site to Cloudflare's global network...
17:10:54.054 Uploading... (631/631)
17:10:54.055
17:10:54.057 ✨ Success! Uploaded 0 files (631 already uploaded) (0.73 sec)
17:10:54.058
17:10:54.645 ✨ Upload complete!
17:10:56.144 Success: Assets published!
17:10:56.950 Error: Failed to publish your Function. Got error: Uncaught ReferenceError: context is not defined
at functionsWorker-0.047060805545406925.js:892:27
I can solve the problem by putting the key directly into _middleware.ts and not relying on the environment variable (which I have done verbatim to the instructions). I’d rather fix it properly but without much free time, is the key in _middleware.ts ok for now?