diff --git a/src/services/marquinhosApi.ts b/src/services/marquinhosApi.ts index 9929f72..4ace645 100644 --- a/src/services/marquinhosApi.ts +++ b/src/services/marquinhosApi.ts @@ -1,6 +1,23 @@ import axios from 'axios'; +import { readFileSync } from 'fs'; +import { Agent } from 'https'; +import { join } from 'path'; import { LastfmTopListenedPeriod, PlaybackData } from '@marquinhos/types'; +const httpsAgent = new Agent({ + cert: + process.env.NODE_ENV === 'production' + ? readFileSync(join(__dirname, '/etc/ssl/certificate.pem')) + : undefined, + key: + process.env.NODE_ENV === 'production' + ? readFileSync(join(__dirname, '/etc/ssl/private.pem')) + : undefined, + rejectUnauthorized: process.env.NODE_ENV === 'production', +}); + +axios.defaults.httpsAgent = httpsAgent; + export class MarquinhosApiService { async addToScrobbleQueue(playbackData: PlaybackData) { const options = {