In the Browser
In browser-based applications, you should never expose your access key directly in your front-end code. Instead, proxy your requests through a backend route that handles the access key securely. Here’s how you can do it:Create a Frontend Client
In the browser, the Muna client should reference an API route on your backend. For example:page.tsx
Create a Backend Route
On the backend, create an API route that securely handles the access key. For example, if you’re using the Next.js App Router, you can define a route like this:route.ts
Make sure to not pass in any
inputs
when creating a prediction on the backend.In Node.js
For Node.js applications, storing your access key in environment variables is a best practice. This keeps the key out of your codebase and secure on your system.Create a Dotenv File
Create a.env
file in the root of your project and store your access key like this:
.env
.env
file:
.env
file is never committed to version control by adding it to your .gitignore
:
.gitignore
Create a Muna Client
The Muna client will automatically load the access key from the environment variable when instantiated in your code:In Unity Engine
In Unity applications, we strongly recommend following the same approach as in the browser:.gitignore