I am buidling an app that uses OpenAI's API (with Next.js and Vercel). In order to make it work, I can let the frontend make the API call directly. However, doing so will expose the API key to the browser (I know it's never safe to store secrets in the frontend side). Thus, I'm wondering what is the easiest way to run a backend service and make the api call? Since the only goal is to hide my API key, I would prefer a super lightweight solution. Thanks guys.
I tried using Environment Variables in Vercel, however it seems still require a backend service.