Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions sample-apps/react/react-dogfood/helpers/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,15 @@ export const getClient = (

const basePath = process.env.NEXT_PUBLIC_BASE_PATH || '';

export const createTokenProvider =
(userId: string | undefined, environment: AppEnvironment) => async () => {
export const createTokenProvider = (
userId: string | undefined,
environment: AppEnvironment,
) => {
if (process.env.NEXT_PUBLIC_APP_ENVIRONMENT === 'pronto-sales') {
return undefined;
}

return async () => {
const params = new URLSearchParams({
user_id: userId || '!anon',
environment,
Expand All @@ -58,3 +65,4 @@ export const createTokenProvider =
const json = await ((await res.json()) as Promise<CreateJwtTokenResponse>);
return json.token;
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ const createJwtToken = async (
req: NextApiRequest,
res: NextApiResponse<CreateJwtTokenResponse | CreateJwtTokenErrorResponse>,
) => {
if (process.env.NEXT_PUBLIC_APP_ENVIRONMENT === 'pronto-sales') {
return error(res, 'This endpoint is not enabled', 404);
}

const {
user_id: userId,
api_key: apiKeyFromRequest,
Expand Down