Developing Capabilities
Manage block access
Managing Loader/Action Access
By default, all loaders and actions in deco.cx are publicly accessible. However, you may need to restrict access to certain loaders/actions that handle sensitive operations or private APIs. This guide explains how to control loader/action visibility.
Visibility Options
There are two visibility levels available:
private
: Can only be invoked server-side throughctx.invoke
public
: Can be called from both server and client through:- Runtime
invoke
calls - Direct path access via
/live/invoke/{path/to/block.ts}
- Runtime
Setting Default Visibility
To set the visibility level for a loader/action, export a defaultVisibility
variable:
Overriding Visibility
You can override the default visibility settings in your fresh.config.ts
file using the visibilityOverrides
option:
Security Best Practices
When deciding visibility levels:
Use private
for
- Accessing private/internal APIs
- Operations involving credentials or secrets
- Processing sensitive user/business data
- Backend integrations requiring authentication
Use public
for
- Reading public product data
- Fetching public content
- Client-side data loading
- User-facing operations that don’t expose sensitive data
Related Documentation
Was this page helpful?