mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 16:03:21 +00:00
feat: Signatures électroniques docuseal [#22]
This commit is contained in:
31
Front-End/src/pages/api/docuseal/generateToken.js
Normal file
31
Front-End/src/pages/api/docuseal/generateToken.js
Normal file
@ -0,0 +1,31 @@
|
||||
import { BE_DOCUSEAL_GET_JWT } from '@/utils/Url';
|
||||
|
||||
export default function handler(req, res) {
|
||||
if (req.method === 'POST') {
|
||||
console.log('DOCUSEAL_API_KEY:', process.env.DOCUSEAL_API_KEY);
|
||||
|
||||
fetch(BE_DOCUSEAL_GET_JWT, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Auth-Token': process.env.DOCUSEAL_API_KEY
|
||||
},
|
||||
body: JSON.stringify(req.body),
|
||||
})
|
||||
.then(response => {
|
||||
console.log('Response status:', response.status);
|
||||
return response.json().then(data => ({ status: response.status, data }));
|
||||
})
|
||||
.then(({ status, data }) => {
|
||||
console.log('Response data:', data);
|
||||
res.status(status).json(data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.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`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user