Moved later/gitgram-ai/gitgram/ to apps/ritgram/ (fresh history; full history stays in caelum0x/gitgram). AITimeMachine stays separate in later/gitgram-ai per the Rithub master plan. Logs, pid files and env files are ignored; GPL-3.0 mobile/proximity noted in THIRD_PARTY_NOTICES. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
36 lines
780 B
TypeScript
36 lines
780 B
TypeScript
import { cookies } from 'next/headers'
|
|
|
|
export async function getServerSession() {
|
|
try {
|
|
const cookieStore = await cookies()
|
|
const token = cookieStore.get('auth-token')?.value
|
|
|
|
if (!token) {
|
|
return null
|
|
}
|
|
|
|
// Verify token with backend
|
|
const apiUrl = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:4000/api'
|
|
const response = await fetch(`${apiUrl}/v1/auth/verify`, {
|
|
method: 'GET',
|
|
headers: {
|
|
'Authorization': `Bearer ${token}`,
|
|
},
|
|
cache: 'no-store',
|
|
})
|
|
|
|
if (!response.ok) {
|
|
return null
|
|
}
|
|
|
|
const data = await response.json()
|
|
return {
|
|
user: data.user,
|
|
token: token,
|
|
}
|
|
} catch (error) {
|
|
console.error('Server session check error:', error)
|
|
return null
|
|
}
|
|
}
|