Skip to content

Commit

Permalink
Support secure connections to the homeserver in MediaProxy (#508)
Browse files Browse the repository at this point in the history
* Support secure connections to the homeserver in MediaProxy

Fixes GH-507

* changelog
  • Loading branch information
tadzik authored Sep 13, 2024
1 parent 647a412 commit a76ce43
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/508.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Support secure connections to the homeserver in MediaProxy.
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 a76ce43

Please sign in to comment.