2024-03-02 00:51:43 -05:00
|
|
|
import { getAccessToken, withApiAuthRequired } from '@auth0/nextjs-auth0';
|
|
|
|
import axios from 'axios';
|
|
|
|
import fs from 'fs';
|
|
|
|
import path from 'path';
|
|
|
|
|
2024-03-03 16:19:47 -05:00
|
|
|
export default withApiAuthRequired(async function handler(req, res) {
|
2024-03-02 00:51:43 -05:00
|
|
|
const { accessToken } = await getAccessToken(req, res);
|
|
|
|
const requestId = req.query.requestId;
|
|
|
|
const assetId = req.query.assetId;
|
|
|
|
const response = await axios({
|
|
|
|
method: 'get',
|
|
|
|
url: `${process.env.NEXT_PUBLIC_API_URL}/api/Requests/Customer/${requestId}/Assets/${assetId}`,
|
|
|
|
responseType: 'stream',
|
|
|
|
headers: {
|
|
|
|
|
|
|
|
"Authorization": `Bearer ${accessToken}`,
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
res.setHeader('Content-Type', response.headers['content-type']);
|
|
|
|
|
|
|
|
// Pipe the response stream directly to the response of the Next.js API Route
|
|
|
|
response.data.pipe(res);
|
|
|
|
});
|