Skip to content

Commit da46e12

Browse files
committed
address ai based feedback
1 parent 7e8b981 commit da46e12

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

src/lib/api-client.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,17 @@ export async function getAuthenticatedClient(accessToken?: string) {
6868
accessToken = token;
6969
}
7070

71-
// Check for mock scenario cookie (development only)
7271
const requestHeaders: Record<string, string> = {
7372
Authorization: `Bearer ${accessToken}`,
7473
};
7574

76-
const cookieStore = await cookies();
77-
const mockScenario = cookieStore.get(MOCK_SCENARIO_COOKIE)?.value;
78-
if (mockScenario) {
79-
requestHeaders[MOCK_SCENARIO_HEADER] = mockScenario;
75+
// Mock scenario header is only used in development for testing different backend states
76+
if (process.env.NODE_ENV === "development") {
77+
const cookieStore = await cookies();
78+
const mockScenario = cookieStore.get(MOCK_SCENARIO_COOKIE)?.value;
79+
if (mockScenario) {
80+
requestHeaders[MOCK_SCENARIO_HEADER] = mockScenario;
81+
}
8082
}
8183

8284
// Create a new client instance per request to avoid race conditions

src/mocks/mockScenario.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,10 @@ export function mockScenario(
2929
): HttpHandler =>
3030
httpMethod(path, (info) => {
3131
const headerValue = info.request.headers.get(SCENARIO_HEADER);
32-
console.log(
33-
`[mockScenario] ${method.toUpperCase()} ${info.request.url}`,
34-
`| header "${SCENARIO_HEADER}"="${headerValue}"`,
35-
`| expected="${scenario}"`,
36-
`| match=${headerValue === scenario}`,
37-
);
3832

3933
if (headerValue !== scenario) {
4034
return;
4135
}
42-
console.log(`[mockScenario] ACTIVATED scenario "${scenario}"`);
4336
return handler(info);
4437
});
4538
},

0 commit comments

Comments
 (0)