|
1 | 1 | import { z } from "zod"; |
2 | | -import { |
3 | | - NEXT_PUBLIC_DASHBOARD_CLIENT_ID, |
4 | | - NEXT_PUBLIC_THIRDWEB_API_HOST, |
5 | | -} from "@/constants/public-envs"; |
6 | 2 | import { getVercelEnv } from "@/utils/vercel"; |
7 | 3 |
|
8 | 4 | type SupportFeedbackInput = { |
@@ -31,26 +27,32 @@ export async function submitSupportFeedback( |
31 | 27 | const input = parsed.data; |
32 | 28 |
|
33 | 29 | try { |
34 | | - // Use fallback client ID if not configured (following codebase pattern) |
35 | | - const clientId = NEXT_PUBLIC_DASHBOARD_CLIENT_ID || "dummy-build-client"; |
| 30 | + const apiKey = process.env.NEXT_PUBLIC_DASHBOARD_CLIENT_ID; |
| 31 | + if (!apiKey) { |
| 32 | + return { error: "NEXT_PUBLIC_DASHBOARD_CLIENT_ID not configured" }; |
| 33 | + } |
| 34 | + |
| 35 | + // Use the main API host, not SIWA |
| 36 | + const apiHost = process.env.NEXT_PUBLIC_THIRDWEB_API_HOST; |
| 37 | + if (!apiHost) { |
| 38 | + return { error: "NEXT_PUBLIC_THIRDWEB_API_HOST not configured" }; |
| 39 | + } |
| 40 | + |
36 | 41 | const vercelEnv = getVercelEnv(); |
37 | 42 | const isPreview = vercelEnv === "preview" || vercelEnv === "development"; |
38 | 43 |
|
39 | | - const response = await fetch( |
40 | | - `${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/csat/saveCSATFeedback`, |
41 | | - { |
42 | | - method: "POST", |
43 | | - headers: { |
44 | | - "Content-Type": "application/json", |
45 | | - "x-service-api-key": clientId, |
46 | | - }, |
47 | | - body: JSON.stringify({ |
48 | | - rating: input.rating, |
49 | | - feedback: input.feedback, |
50 | | - ticket_id: input.ticketId, |
51 | | - }), |
| 44 | + const response = await fetch(`${apiHost}/v1/csat/saveCSATFeedback`, { |
| 45 | + method: "POST", |
| 46 | + headers: { |
| 47 | + "Content-Type": "application/json", |
| 48 | + "x-service-api-key": apiKey, |
52 | 49 | }, |
53 | | - ); |
| 50 | + body: JSON.stringify({ |
| 51 | + rating: input.rating, |
| 52 | + feedback: input.feedback, |
| 53 | + ticket_id: input.ticketId, |
| 54 | + }), |
| 55 | + }); |
54 | 56 |
|
55 | 57 | if (!response.ok) { |
56 | 58 | if (response.status === 404 && isPreview) { |
|
0 commit comments