feat: Secure API routes with authentication checks and enhance redirect handling for unauthenticated users.

This commit is contained in:
2026-02-03 18:51:16 +00:00
parent 7c6d1cd681
commit be7db36126
9 changed files with 90 additions and 13 deletions

View File

@@ -91,8 +91,18 @@ export default function OpportunitiesPage() {
}
fetch('/api/opportunities')
.then(r => r.json())
.then(data => setPlatforms(data.platforms))
.then(r => {
if (r.redirected) {
router.push('/auth?next=/opportunities')
return null
}
return r.json()
})
.then(data => {
if (data) {
setPlatforms(data.platforms)
}
})
}, [router])
const togglePlatform = (platformId: string) => {
@@ -129,6 +139,11 @@ export default function OpportunitiesPage() {
body: JSON.stringify({ analysis, config })
})
if (response.redirected) {
router.push('/auth?next=/opportunities')
return
}
const data = await response.json()
if (data.success) {