added login and sign Funtion properly
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
import axios, { AxiosError } from 'axios';
|
||||
import serversideConfig from '../../serversideConfig';
|
||||
import fs from 'fs';
|
||||
import https from 'https';
|
||||
|
||||
let loginSuccessful = false;
|
||||
@ -8,31 +7,22 @@ let errorMsg = '';
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
loginSuccessful = false;
|
||||
const agent = new https.Agent({
|
||||
rejectUnauthorized: false,
|
||||
});
|
||||
|
||||
const axiosInstance = axios.create({
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Accept: "*",
|
||||
},
|
||||
httpsAgent: agent
|
||||
});
|
||||
|
||||
if (event.path.startsWith("/api/login")) {
|
||||
|
||||
const body = await readBody(event)
|
||||
|
||||
// read the certificate and create agent
|
||||
const caCert = fs.readFileSync('./certs/server_ca.pem');
|
||||
// const httpsAgent = new https.Agent({
|
||||
// keepAlive: true,
|
||||
// ca: caCert,
|
||||
// rejectUnauthorized: true,
|
||||
// });
|
||||
|
||||
const agent = new https.Agent({
|
||||
rejectUnauthorized: false,
|
||||
});
|
||||
|
||||
const axiosInstance = axios.create({
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Accept: "*",
|
||||
},
|
||||
httpsAgent: agent
|
||||
});
|
||||
|
||||
// get user object from backend
|
||||
try {
|
||||
let res = await axiosInstance.post(`https://${serversideConfig.url}:${serversideConfig.port}/login`, {
|
||||
|
||||
Reference in New Issue
Block a user