Widget Embedding
The MLM Platform provides embeddable widgets for displaying referral information and capturing leads.
Overview
Widgets are embedded using iframes with JWT-based authentication (Widget Access Tokens or WATs).
Before embedding widgets, configure allowed origins in the Admin Dashboard:
- Navigate to Settings > Widget Configuration
- Add your application’s origin(s):
https://yourapp.com
https://www.yourapp.com
http://localhost:3000 (for development)
- Click Save
Only add origins you control. Unauthorized origins will be rejected.
Request a WAT from your backend:
Response:
Use the token to embed the widget iframe:
React Component
Displays the user’s referral link with copy functionality:
Shows commission balance and history:
Form for capturing leads with referral attribution:
Content Security Policy (CSP)
If your application uses CSP, add the widget domain to frame-src:
Or in Next.js middleware:
Token Refresh
WATs expire after 1 hour. Implement token refresh:
Troubleshooting
- Check origin configuration: Verify your origin is in the allowed list
- Check token: Ensure token is valid and not expired
- Check CSP: Verify frame-src allows the widget domain
- Check browser console: Look for CORS or CSP errors
CORS Errors
Solution: Add the widget domain to your CSP frame-src directive.
Token Expired
Solution: Implement token refresh as shown above.
Origin Not Allowed
Solution: Add your origin to the allowed origins list in the Admin Dashboard.