Skip to content

Commit c7bdfe6

Browse files
committed
feat: always add dnt=gateway header for gateway connections
1 parent 1e5bbc6 commit c7bdfe6

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

packages/server-core-integration/src/lib/ddpClient.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,13 @@ export class DDPClient extends EventEmitter<DDPClientEvents> {
719719
})
720720
}
721721

722+
private getHeadersWithDefaults(): { [header: string]: string } {
723+
return {
724+
dnt: 'gateway', // Provide the header needed for the header based auth to work when not connected through a reverse proxy
725+
...this.headers,
726+
}
727+
}
728+
722729
private async makeSockJSConnection(): Promise<void> {
723730
const protocol = this.ssl ? 'https://' : 'http://'
724731
if (this.path && !this.path?.endsWith('/')) {
@@ -728,7 +735,7 @@ export class DDPClient extends EventEmitter<DDPClientEvents> {
728735

729736
try {
730737
const response = await got(url, {
731-
headers: this.headers,
738+
headers: this.getHeadersWithDefaults(),
732739
https: {
733740
certificateAuthority: this.tlsOpts.ca,
734741
key: this.tlsOpts.key,
@@ -769,7 +776,7 @@ export class DDPClient extends EventEmitter<DDPClientEvents> {
769776

770777
private makeWebSocketConnection(url: string): void {
771778
// console.log('About to create WebSocket client')
772-
this.socket = new WebSocket.Client(url, null, { tls: this.tlsOpts, headers: this.headers })
779+
this.socket = new WebSocket.Client(url, null, { tls: this.tlsOpts, headers: this.getHeadersWithDefaults() })
773780

774781
this.socket.on('open', () => {
775782
// just go ahead and open the connection on connect

0 commit comments

Comments
 (0)