mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +00:00
35 lines
1004 B
JavaScript
35 lines
1004 B
JavaScript
import logger from '@/utils/logger';
|
|
import { BE_DOCUSEAL_GET_JWT } from '@/utils/Url';
|
|
|
|
export default function handler(req, res) {
|
|
if (req.method === 'POST') {
|
|
const { apiDocuseal, ...rest } = req.body;
|
|
|
|
fetch(BE_DOCUSEAL_GET_JWT, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'X-Auth-Token': apiDocuseal,
|
|
},
|
|
body: JSON.stringify(rest),
|
|
})
|
|
.then((response) => {
|
|
logger.debug('Response status:', response.status);
|
|
return response
|
|
.json()
|
|
.then((data) => ({ status: response.status, data }));
|
|
})
|
|
.then(({ status, data }) => {
|
|
logger.debug('Response data:', data);
|
|
res.status(status).json(data);
|
|
})
|
|
.catch((error) => {
|
|
logger.error('Error:', error);
|
|
res.status(500).json({ error: 'Internal Server Error' });
|
|
});
|
|
} else {
|
|
res.setHeader('Allow', ['POST']);
|
|
res.status(405).end(`Method ${req.method} Not Allowed`);
|
|
}
|
|
}
|