Skip to content

Commit 277ee3b

Browse files
committed
refactor: enhance logging and update trusted origins in auth configuration
- Added console log statements in the getTask function to improve traceability during task fetching, including success and error handling. - Updated the trustedOrigins array in the auth configuration to include new portal URLs, enhancing environment-specific authentication handling.
1 parent d2e3e32 commit 277ee3b

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

apps/app/src/app/(app)/[orgId]/tasks/[taskId]/page.tsx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,29 @@ export default async function TaskPage({
3737
}
3838

3939
const getTask = async (taskId: string, session: Session) => {
40+
console.log('[getTask] Starting task fetch for:', taskId);
4041
const activeOrgId = session?.session.activeOrganizationId;
4142

4243
if (!activeOrgId) {
4344
console.warn('Could not determine active organization ID in getTask');
4445
return null;
4546
}
4647

47-
const task = await db.task.findUnique({
48-
where: {
49-
id: taskId,
50-
organizationId: activeOrgId,
51-
},
52-
});
48+
console.log('[getTask] Querying database for task');
49+
try {
50+
const task = await db.task.findUnique({
51+
where: {
52+
id: taskId,
53+
organizationId: activeOrgId,
54+
},
55+
});
5356

54-
return task;
57+
console.log('[getTask] Database query successful');
58+
return task;
59+
} catch (error) {
60+
console.error('[getTask] Database query failed:', error);
61+
throw error;
62+
}
5563
};
5664

5765
const getComments = async (taskId: string, session: Session): Promise<CommentWithAuthor[]> => {

apps/app/src/utils/auth.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ export const auth = betterAuth({
5050
'http://localhost:3000',
5151
'https://app.trycomp.ai',
5252
'https://app.staging.trycomp.ai',
53+
'https://portal.trycomp.ai',
54+
'https://portal.staging.trycomp.ai',
5355
],
5456
emailAndPassword: {
5557
enabled: true,

apps/portal/src/app/lib/auth.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ export const auth = betterAuth({
1515
// It's important so we can use custom IDs specified in Prisma Schema.
1616
generateId: false,
1717
},
18+
trustedOrigins: [
19+
'http://localhost:3000',
20+
'https://app.trycomp.ai',
21+
'https://app.staging.trycomp.ai',
22+
'https://portal.trycomp.ai',
23+
'https://portal.staging.trycomp.ai',
24+
],
1825
secret: process.env.AUTH_SECRET!,
1926
plugins: [
2027
organization({

0 commit comments

Comments
 (0)