Skip to content

Securing and Accessing API Endpoints

A frontend application using the BFF pattern can call two types of APIs: embedded (local) APIs, and proxied remote APIs.

Use the table below for additional guidance on token requirements:

ScenarioRecommended approach
API is only used by this frontendEmbedded (Local) API
API is shared by multiple clients or deployed separatelyRemote API — Direct Forwarding
Complex routing, load balancing, or transforms are neededYARP
API requires the logged-in user’s tokenRemote or YARP with RequiredTokenType.User
API uses machine-to-machine (client credentials) authRemote or YARP with RequiredTokenType.Client
API is publicly accessible (no auth required)Remote with RequiredTokenType.None
API should use user token if logged in, anonymous otherwiseRemote or YARP with RequiredTokenType.UserOrNone

These APIs are embedded inside the BFF and typically exist to support the BFF’s frontend; they are not shared with other frontends or services.

See Embedded APIs for more information.

These APIs are deployed on a different host than the BFF, which allows them to be shared between multiple frontends or (more generally speaking) multiple clients. These APIs can only be called via the BFF host acting as a proxy.

You can use Direct Forwarding for most scenarios. If you have more complex requirements, you can also directly interact with YARP.