How to use convex in a server-only environment?
How can I use convex outside of the main client application so that I can query data arbitarily and that I have a set of functions that can only be accessed by the server and not by any user?
In a supabase application, I can spin up a new server-side js file via bun and use prisma to query files
How can I do the equivalent using convex?
7 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
I would just set a password as an environment variable and pass that to whatever functions you want to be server-only.
I get that but that definitely feels like a hack. Is there an internal functions equivalent that might make more sense?
Not to my knowledge
You would generally use a shared secret for this. You could use a single http action to handle request/response, check the secret, and have all function calls from the http action be internal.
What is a shared secret?
Generating a secret and having one service send the secret to the other with each request as validation.