Skip to content

Commit

Permalink
Support secure connections to the homeserver in MediaProxy
Browse files Browse the repository at this point in the history
Fixes GH-507
  • Loading branch information
tadzik committed Sep 13, 2024
1 parent 647a412 commit 4f57121
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/components/media-proxy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { webcrypto } from 'node:crypto';
import { Request, Response, default as express, NextFunction, Router } from 'express';
import { ApiError, IApiError, Logger, ErrCode } from '..';
import { Server, get } from 'http';
import { Server, get as httpGet } from 'http';
import { get as httpsGet } from "https";
import { MatrixClient } from '@vector-im/matrix-bot-sdk';
const subtleCrypto = webcrypto.subtle;
const log = new Logger('MediaProxy');
Expand Down Expand Up @@ -153,6 +154,7 @@ export class MediaProxy {
}
const [, serverName, mediaId] = mxcMatch;
const url = `${this.matrixClient.homeserverUrl}/_matrix/client/v1/media/download/${serverName}/${mediaId}`;
const get = url.startsWith("https:") ? httpsGet : httpGet;
return new Promise<void>((resolve, reject) => {
get(url, {
headers: {
Expand Down

0 comments on commit 4f57121

Please sign in to comment.