-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
38 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (c) 2024 Seagate Technology LLC and/or its Affiliates | ||
import axios, { AxiosInstance } from 'axios'; | ||
import { DefaultApi } from "@/axios/api"; | ||
import type { Configuration } from '@/axios/configuration'; | ||
import https from 'https'; | ||
import fs from 'fs'; | ||
|
||
// Load the certificate | ||
const cert = fs.readFileSync('/usr/local/share/ca-certificates/github_com_seagate_cfm-self-signed.crt'); | ||
// Use API_BASE_PATH to overwrite the BASE_PATH in the generated client code | ||
const API_BASE_PATH = process.env.BASE_PATH; | ||
|
||
// Create a custom Axios instance with HTTPS configuration | ||
const axiosInstance: AxiosInstance = axios.create({ | ||
baseURL: API_BASE_PATH, | ||
httpsAgent: new https.Agent({ | ||
ca: cert, | ||
rejectUnauthorized: false, | ||
}), | ||
headers: { | ||
'Content-Type': 'application/json', | ||
} | ||
}); | ||
|
||
// Extend the DefaultApi class to use the custom Axios instance | ||
export class CustomApi extends DefaultApi { | ||
constructor(configuration?: Configuration, basePath?: string) { | ||
super(configuration, basePath, axiosInstance); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters