Skip to content

Commit 0d8a52f

Browse files
committed
fix: use API_SERVER_SECRET for CSAT endpoint following codebase standards
1 parent 9f703ab commit 0d8a52f

File tree

1 file changed

+19
-17
lines changed
  • apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/support/apis

1 file changed

+19
-17
lines changed

apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/support/apis/feedback.ts

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { z } from "zod";
2+
import { NEXT_PUBLIC_THIRDWEB_API_HOST } from "@/constants/public-envs";
3+
import { API_SERVER_SECRET } from "@/constants/server-envs";
24
import { getVercelEnv } from "@/utils/vercel";
35

46
type SupportFeedbackInput = {
@@ -27,29 +29,29 @@ export async function submitSupportFeedback(
2729
const input = parsed.data;
2830

2931
try {
30-
const apiKey = process.env.NEXT_PUBLIC_DASHBOARD_CLIENT_ID;
31-
if (!apiKey) {
32-
return { error: "NEXT_PUBLIC_DASHBOARD_CLIENT_ID not configured" };
32+
if (!API_SERVER_SECRET) {
33+
return { error: "API_SERVER_SECRET not configured" };
3334
}
3435

35-
// Use the main API host, not SIWA
36-
const apiHost = process.env.NEXT_PUBLIC_THIRDWEB_API_HOST;
37-
if (!apiHost) {
36+
if (!NEXT_PUBLIC_THIRDWEB_API_HOST) {
3837
return { error: "NEXT_PUBLIC_THIRDWEB_API_HOST not configured" };
3938
}
4039

41-
const response = await fetch(`${apiHost}/v1/csat/saveCSATFeedback`, {
42-
method: "POST",
43-
headers: {
44-
"Content-Type": "application/json",
45-
"x-service-api-key": apiKey,
40+
const response = await fetch(
41+
`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/csat/saveCSATFeedback`,
42+
{
43+
method: "POST",
44+
headers: {
45+
"Content-Type": "application/json",
46+
"x-service-api-key": API_SERVER_SECRET,
47+
},
48+
body: JSON.stringify({
49+
rating: input.rating,
50+
feedback: input.feedback,
51+
ticket_id: input.ticketId,
52+
}),
4653
},
47-
body: JSON.stringify({
48-
rating: input.rating,
49-
feedback: input.feedback,
50-
ticket_id: input.ticketId,
51-
}),
52-
});
54+
);
5355

5456
if (!response.ok) {
5557
// Check if we're in a preview environment (Vercel preview deployments)

0 commit comments

Comments
 (0)