Backend
Astro
Add Vox to your Astro project.
To add the backend integration to your Astro project, you need to create a new file src/pages/api/feedback.ts
and add the following code:
import { createFeedbackHandler } from "voxjs/server";
import type { APIRoute } from "astro";
import { getSession } from "~/lib/auth";
import { env } from "~/env";
export const POST: APIRoute = async ({ request }) => {
const session = await getSession(request); // Your custom auth logic.
if (!session) {
return new Response(JSON.stringify({ error: "Unauthorized" }), {
status: 401,
headers: { "Content-Type": "application/json" },
});
}
return createFeedbackHandler({
apiKey: env.FEEDBACK_KEY, // Your Vox API key.
tags: {
app: "my-app", // Your app name.
user: session.user.email,
},
})(request);
};