Skip to content
12 changes: 12 additions & 0 deletions app/api/annotations/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ export async function GET(request: NextRequest) {
return NextResponse.json({ error: "repositoryId is required" }, { status: 400 });
}

// Verify user has access to the repository to prevent IDOR
const repo = await prisma.repository.findFirst({
where: {
id: parseInt(repositoryId),
userId: user.userId,
}
});

if (!repo) {
return NextResponse.json({ error: "Repository not found or access denied" }, { status: 403 });
}

const annotations = await prisma.mapAnnotation.findMany({
where: {
repositoryId: parseInt(repositoryId),
Expand Down
11 changes: 8 additions & 3 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ const nextConfig = {
},
}

const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})
let withBundleAnalyzer;
try {
withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
} catch {
withBundleAnalyzer = (config) => config;
}

module.exports = withBundleAnalyzer(nextConfig)
Loading