обновление бизнес логики
This commit is contained in:
@@ -3,7 +3,7 @@ import { getServerSession } from 'next-auth'
|
||||
import { authOptions } from '@/lib/auth'
|
||||
import * as statusColors from '@/lib/statusColors'
|
||||
|
||||
export async function GET() {
|
||||
export async function GET(request: Request) {
|
||||
try {
|
||||
const session = await getServerSession(authOptions)
|
||||
if (!session?.accessToken) {
|
||||
@@ -11,9 +11,20 @@ export async function GET() {
|
||||
}
|
||||
|
||||
const backendUrl = process.env.BACKEND_URL
|
||||
|
||||
// Получаем zone_id из query параметров
|
||||
const { searchParams } = new URL(request.url)
|
||||
const zoneId = searchParams.get('zone_id')
|
||||
|
||||
// Формируем URL для бэкенда с zone_id если он есть
|
||||
const detectorsUrl = zoneId
|
||||
? `${backendUrl}/account/get-detectors/?zone_id=${zoneId}`
|
||||
: `${backendUrl}/account/get-detectors/`
|
||||
|
||||
console.log('[get-detectors] Fetching from backend:', detectorsUrl)
|
||||
|
||||
const [detectorsRes, objectsRes] = await Promise.all([
|
||||
fetch(`${backendUrl}/account/get-detectors/`, {
|
||||
fetch(detectorsUrl, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${session.accessToken}`,
|
||||
|
||||
Reference in New Issue
Block a user