feat: Secure API routes with authentication checks and enhance redirect handling for unauthenticated users.
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user