diff --git a/app/instagram/video/page.tsx b/app/instagram/video/page.tsx index b33a339..4088bef 100644 --- a/app/instagram/video/page.tsx +++ b/app/instagram/video/page.tsx @@ -34,7 +34,6 @@ function Searchbar({}: Props) { console.log(data); if (data === "link is wrong") { - // console.log("hello"); setloading(false); toast("Check the Provided Link"); } diff --git a/pages/api/download.ts b/pages/api/download.ts index 9d89aeb..e040e1d 100644 --- a/pages/api/download.ts +++ b/pages/api/download.ts @@ -1,5 +1,32 @@ +import { NextApiRequest, NextApiResponse } from 'next'; +// import axios from 'axios'; +export default async function handler(req: NextApiRequest, res: NextApiResponse) { + let { url } = req.query; + + if (typeof url === 'string') { + url = url.replace(/\?utm_source=ig_web_copy_link$/, ''); + url = url.replace(/\?hl=en$/, ''); + url = url.replace(/\?igsh=MWNqM3Jkemx0ZGNpaA==$/, ''); + url = url.replace(/\/[^/]*$/, ''); + url = url + process.env.SECRET_KEY; + console.log(url) + } + + try { +console.log("hello") + const response = await fetch(url as string); + + const data = await response.json(); + res.status(200).send(data); + } catch (error) { + res.status(500).send('error'); + } +} + + // import { NextApiRequest, NextApiResponse } from 'next'; +// import axios from 'axios'; // export default async function handler(req: NextApiRequest, res: NextApiResponse) { // let { url } = req.query; @@ -9,44 +36,17 @@ // url = url.replace(/\?hl=en$/, ''); // url = url.replace(/\?igsh=MWNqM3Jkemx0ZGNpaA==$/, ''); // url = url.replace(/\/[^/]*$/, ''); -// url = url + process.env.SECRET_KEY; +// url = url + "/?__a=1&__d=dis"; // console.log(url) // } // try { - -// const response = await fetch(url as string); - -// const data = await response.json(); -// res.status(200).send(data); +// const response = await axios.get(url as string); +// console.log(response.data) +// const data = response.data; +// res.status(200).json(data); // } catch (error) { -// res.status(500).send('error'); +// console.error(error); +// res.status(500).json({ error: 'Internal Server Error' }); // } // } - - -import { NextApiRequest, NextApiResponse } from 'next'; -import axios from 'axios'; - -export default async function handler(req: NextApiRequest, res: NextApiResponse) { - let { url } = req.query; - - if (typeof url === 'string') { - url = url.replace(/\?utm_source=ig_web_copy_link$/, ''); - url = url.replace(/\?hl=en$/, ''); - url = url.replace(/\?igsh=MWNqM3Jkemx0ZGNpaA==$/, ''); - url = url.replace(/\/[^/]*$/, ''); - url = url + "/?__a=1&__d=dis"; - console.log(url) - } - - try { - const response = await axios.get(url as string); -console.log(response.data) - const data = response.data; - res.status(200).json(data); - } catch (error) { - console.error(error); - res.status(500).json({ error: 'Internal Server Error' }); - } -}