HTTPS Agent Configuration #667
-
|
Good morning, I searched the documentation and couldn't find anything that could help me. How could I configure an HTTPS agent in the request? I know that in Axios, I can do it this way (the method I'm currently using): Since I intend to change from Axios to Ky, how could I configure the certificates? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
See: #526 (comment) |
Beta Was this translation helpful? Give feedback.
-
|
After some digging and trial and error, I found that this works: import { Agent } from 'undici';
import fs from 'fs';
import ky from 'ky';
const customCa = fs.readFileSync('./path/to/your/ca.pem');
const dispatcher = new Agent({
connect: {
ca: customCa,
// key, cert, etc., can also be included in 'connect'
}
});
const data = await ky('https://example.com', { dispatcher }).json();Apparently fetch('https://example.com', { dispatcher })
.then(response => response.json()); |
Beta Was this translation helpful? Give feedback.
See: #526 (comment)