Skip to content

Commit

Permalink
api route
Browse files Browse the repository at this point in the history
  • Loading branch information
s-alad committed Mar 29, 2024
1 parent 33b3a93 commit bc46a6a
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions client/pages/api/proxy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import type { NextApiRequest, NextApiResponse } from 'next'
import axios from 'axios';
import { BEREAL_SIGNATURE } from '@/utils/constants';

//testing vercel headers

export default async function handler(req: NextApiRequest, res: NextApiResponse) {

let uri = req.query.uri;

if (!uri) {
res.status(400).json({ status: "error" });
return;
}

let headers = {
"bereal-app-version-code": "14549",
"bereal-signature": BEREAL_SIGNATURE,
"bereal-device-id": "berealdeviceid",
}

return axios.request({
url: uri as string,
method: "GET",
headers: headers,
}).then(
(response) => {
console.log("------------------")
console.log("request success");
console.log(response.data);
console.log("------------------")

res.status(200).json(response.data);
}
).catch(
(error) => {
console.log(error);
res.status(400).json({ status: "error" });
}
)
}

0 comments on commit bc46a6a

Please sign in to comment.