allen
allen2y ago

I m running into an issue with the new

I'm running into an issue with the new cron job architecture. The function I wish to invoke from my cron job is one that I wish to be protected by an internal api key so it cant be invoked by clients, as its secret-protected. My api key is stored in environment variables via convex secret manager. There doesnt seem to be away for me to access this data in order to populate the needed api key arg for my function as cron jobs are registered at import time, when env vars arent available. Seems I either need a cron registration method that is executed at the appropriate runtime OR a better way to protect functions from the client.
2 Replies
sshader
sshader2y ago
Have you seen internal functions (came out in the last release)? https://blog.convex.dev/announcing-convex-0-12-0/ + https://docs.convex.dev/functions/internal-functions Sounds like you could define your cron function as an internal function and access your env var inside the function?
The Convex Blog
Announcing Convex 0.12.0
Convex authentication just got even simpler! We now support authentication with Clerk.
Internal Functions | Convex Developer Hub
Internal functions can only be called by other functions,
allen
allenOP2y ago
Awesome, missed that. Had to go heads down into design world the last couple weeks. Y'all move too quick.

Did you find this page helpful?