mirror of
https://github.com/aljazceru/enclava.git
synced 2025-12-18 16:04:28 +01:00
34 lines
924 B
TypeScript
34 lines
924 B
TypeScript
import { NextRequest, NextResponse } from 'next/server'
|
|
|
|
export async function POST(request: NextRequest) {
|
|
try {
|
|
// Get the request body
|
|
const body = await request.json()
|
|
|
|
// Make request to backend auth endpoint without requiring existing auth
|
|
const baseUrl = process.env.INTERNAL_API_URL || process.env.NEXT_PUBLIC_API_URL
|
|
const url = `${baseUrl}/api/v1/auth/login`
|
|
|
|
const response = await fetch(url, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify(body)
|
|
})
|
|
|
|
const data = await response.json()
|
|
|
|
if (!response.ok) {
|
|
return NextResponse.json(data, { status: response.status })
|
|
}
|
|
|
|
return NextResponse.json(data)
|
|
} catch (error) {
|
|
console.error('Error in auth login:', error)
|
|
return NextResponse.json(
|
|
{ error: 'Failed to process login' },
|
|
{ status: 500 }
|
|
)
|
|
}
|
|
} |