Overview
The NetBird Proxy Edge Function provides secure, authenticated access to NetBird API endpoints with automatic audit logging. It acts as a proxy between the Nexus Access Vault frontend and NetBird’s management API. Endpoint:/functions/v1/netbird-proxy?path={api_path}
Authentication: Required (Authorization header with Supabase JWT)
Methods: GET, POST, PUT, DELETE, PATCH
Request Format
Query Parameters
NetBird API path to proxy (e.g.,
/api/peers, /api/groups)Headers
Supabase JWT token:
Bearer {token}Request content type (typically
application/json)Body
The request body is forwarded as-is to NetBird API for non-GET requests.Environment Configuration
Response
The function returns the exact response from NetBird API, including:- Original status code
- Original response body
- CORS headers enabled for browser access
Response varies based on NetBird API endpoint called
Example Requests
List Peers
List All Peers
Get Peer Details
Get Specific Peer
List Groups
List NetBird Groups
Create Setup Key
Create Setup Key
Update Peer
Update Peer Configuration
Delete Peer
Delete Peer
Audit Logging
Every API call through the proxy is automatically logged to theaudit_logs table:
Audit Log Entry
Audit Log Query
View NetBird API Calls
Security Features
Authentication Flow
- Client sends request with Supabase JWT
- Function validates JWT using Supabase Auth
- Function authenticates to NetBird using API key
- Request forwarded to NetBird API
- Response returned to client
- Audit log created in database
API Key Protection
- NetBird API key stored securely in environment variables
- Never exposed to client
- Automatically injected into NetBird requests
- Supports both cloud and self-hosted NetBird instances
CORS Support
The function includes CORS headers:CORS Headers
Error Responses
Authentication Required
Status:401 Unauthorized
Invalid Session
Status:401 Unauthorized
NetBird API Key Not Configured
Status:500 Internal Server Error
NetBird API Error
The function forwards NetBird API errors with original status codes: Status: Varies (400, 404, 500, etc.)Proxy Error
Status:500 Internal Server Error
NetBird API Endpoints
Common NetBird API endpoints accessible through the proxy:Peers
GET /api/peers- List all peersGET /api/peers/{peerId}- Get peer detailsPUT /api/peers/{peerId}- Update peerDELETE /api/peers/{peerId}- Delete peer
Groups
GET /api/groups- List groupsPOST /api/groups- Create groupPUT /api/groups/{groupId}- Update groupDELETE /api/groups/{groupId}- Delete group
Setup Keys
GET /api/setup-keys- List setup keysPOST /api/setup-keys- Create setup keyPUT /api/setup-keys/{keyId}- Update setup keyDELETE /api/setup-keys/{keyId}- Delete setup key
Routes
GET /api/routes- List network routesPOST /api/routes- Create routePUT /api/routes/{routeId}- Update routeDELETE /api/routes/{routeId}- Delete route
DNS
GET /api/dns/nameservers- List DNS nameserversPOST /api/dns/nameservers- Add nameserverGET /api/dns/settings- Get DNS settingsPUT /api/dns/settings- Update DNS settings
Users
GET /api/users- List usersGET /api/users/{userId}- Get user detailsPUT /api/users/{userId}- Update userDELETE /api/users/{userId}- Delete user
Request Logging
The function logs requests to console:Self-Hosted NetBird
For self-hosted NetBird instances, set theNETBIRD_BASE_URL environment variable:
Environment Variable
Related Documentation
Related Tables
audit_logs- API call audit trailprofiles- User authentication