@@ -29,9 +29,11 @@ export default {
2929 const url = new URL ( request . url ) ;
3030 // The address it is reached on, unless a deployment pins another one:
3131 // a placeholder default ships on every deploy and delegates the media
32- // away from this worker.
32+ // away from this worker. The port is always spelled out: a port-less
33+ // delegation sends the requesting server to an SRV lookup and then to
34+ // 8448, which no worker answers on.
3335 const serverName = env . SERVERNAME || url . hostname ;
34- const delegate = env . HOSTNAME ? `${ env . HOSTNAME } :${ env . PORT || 443 } ` : url . host ;
36+ const delegate = `${ env . HOSTNAME || url . hostname } :${ env . PORT || url . port || 443 } ` ;
3537
3638 if ( url . pathname === '/_matrix/federation/v1/version' ) {
3739 return new Response ( JSON . stringify ( returnMatrixServerVers ( ) ) , {
@@ -60,7 +62,9 @@ export default {
6062 mxcId : matrixId
6163 } satisfies SoliditasAddressConvertResponse ) )
6264 } else if ( url . pathname === '/.well-known/matrix/server' ) {
63- return new Response ( JSON . stringify ( { 'm.server' : delegate } satisfies MatrixWellKnownServer ) ) ;
65+ return new Response ( JSON . stringify ( { 'm.server' : delegate } satisfies MatrixWellKnownServer ) , {
66+ headers : { 'Content-Type' : 'application/json' } ,
67+ } ) ;
6468 } else {
6569 return new Response ( JSON . stringify ( matrixEndpointNotImplemented ( 'only implements media endpoints' ) ) , {
6670 headers : { 'Content-Type' : 'application/json' } ,
0 commit comments