Backend for Frontend (BFF) Auth
Optimize UX and security in web applications with this approach.
Backend for Frontend (BFF) Authorization Sample#
This is the source code from the sample discussed in the Backend for Frontend (BFF) Authorization blog post.
Setup#
This sample uses an OAuth identity provider (tested with Auth0) and Upstash. In order to run the sample you will need to set the following environment variables either in your .env
file if you are running locally or in the Zuplo portal if you are running there.
// Auth0 Environment Variables
// Create a Regular Web Application in Auth0
//https://auth0.com/docs/get-started/auth0-overview/create-applications/regular-web-apps
AUTH0_URL=my-url.us.auth0.com
CLIENT_ID=
CLIENT_SECRET=
// Create an Upstash Redis Database
// https://upstash.com/docs/redis/overall/getstarted
UPSTASH_URL=
UPSTASH_TOKEN=
Use this example locally#
To develop with this example locally, you can create a new Zuplo project using our CLI
npx create-zuplo-api@latest my-api --example bff-auth
Then, in the project directory run the following commands:
npm install
npm run dev
Discover More Examples
Remote MCP Server with OAuth
A remote MCP Server that shows how to setup OAuth authentication with Auth0
Dev Portal with API Keys
An example of a Zuplo Dev Portal with support for self-serve API key creation.
Remote MCP Server
Create a remote MCP server for an API with authentication and additional security policies.
Metering with OpenMeter
Meter requests, enforce plan limits and monetize your API by integrating Zuplo with OpenMeter.