The feedback function is a Supabase Edge Function that collects and processes user feedback.
This function allows applications to collect feedback from users and store it in the database. It also supports sending email notifications about new feedback submissions.
- Collect user feedback from various sources
- Store feedback in the database
- Send email notifications about new feedback
- Support for different feedback types (bug reports, feature requests, general feedback)
- CORS support for cross-origin requests
| Variable | Description | Default |
|---|---|---|
RESEND_API_KEY |
API key for the Resend email service | Required |
FEEDBACK_FROM_EMAIL |
Email address to send notifications from | feedback@example.com |
FEEDBACK_REPLY_TO_DOMAIN |
Domain for reply-to email addresses | example.com |
NOTIFICATION_RECIPIENTS |
Comma-separated list of email addresses to notify | Required |
POST /functions/v1/feedback
{
"type": "bug_report",
"subject": "Error when submitting form",
"message": "I encountered an error when trying to submit the contact form.",
"metadata": {
"browser": "Chrome 98.0.4758.102",
"os": "Windows 10",
"url": "https://example.com/contact"
},
"user": {
"id": "user_12345",
"email": "user@example.com",
"name": "John Doe"
}
}{
"success": true,
"feedbackId": "feedback_12345",
"notificationSent": true
}The function returns appropriate HTTP status codes and error messages for various failure scenarios:
400 Bad Request: Missing required fields401 Unauthorized: Invalid authentication500 Internal Server Error: Server-side errors
Feedback is stored in the database with the following information:
- Feedback type, subject, and message
- User information (ID, email, name)
- Metadata (browser, OS, URL)
- Timestamp
- Status (new, in progress, resolved)
- Validates input data
- Sanitizes user input to prevent injection attacks
- Uses authentication to prevent spam