I'm building a static app that uses serverless functions. Could Koii tasks provide the functions?

Expert

I have a next.js app that has 1 function in the pages/api route. I need to remove this to make the app capable of being deployed to IPFS as a static site. This function contains some code and parameters that shouldn't be accessible to the browser so I can't just add the function to a page. Could I replace my pages/api route with a Koii task?

For example let's say I had a next.js app with a button that downloads a file from IPFS when clicked. I want to keep the IPFS CID a secret to the end user, therefore, I can't simply add this function to the page. Could I make a Koii task that fetches and streams this file to the browser for download?

Answers 1

Yes, you can utilize Koii tasks to handle sensitive operations and protect your code and parameters from being accessible to the browser. In your scenario, where you want to remove a function in the pages/api route to make your app deployable to IPFS as a static site, you can consider using a Koii task to achieve the desired functionality.

Instead of directly exposing the function in the pages/api route, you can create a Koii task that fetches and streams the file from IPFS to the browser for download. This way, the sensitive code and parameters will remain secure within the Koii task environment and won't be exposed to the end user.

To implement this, you can define a Koii task that performs the necessary operations to fetch and stream the file from IPFS. You can pass any required parameters securely to the task, ensuring that they are not exposed to the browser. The task can then generate the appropriate response that allows the user to download the file without revealing the IPFS CID or other sensitive information.

By leveraging Koii tasks, you can maintain the desired level of security while providing the necessary functionality to download files from IPFS in your Next.js app.