import type { NextApiRequest, NextApiResponse } from 'next';
import { getEchoHeaders } from '@/src/components/utils';

export default async function GET(req: NextApiRequest, res: NextApiResponse<any>) {
  if (!req.headers['x-echo-url']) {
    return res.status(404).send('No URL provided');
  }

  const response = await fetch(`${req.headers['x-echo-url']}?action=discover`, {
    headers: {},
  });

  const json = await response.json();

  res.json(json.workflows);
}
