Skip to content

Commit

Permalink
feat: always add dnt=gateway header for gateway connections
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Nov 27, 2024
1 parent 5357b65 commit 0bfe9f2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/server-core-integration/src/lib/ddpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,13 @@ export class DDPClient extends EventEmitter<DDPClientEvents> {
})
}

private getHeadersWithDefaults(): { [header: string]: string } {
return {
dnt: 'gateway', // Provide the header needed for the header based auth to work when not connected through a reverse proxy
...this.headers,
}
}

private async makeSockJSConnection(): Promise<void> {
const protocol = this.ssl ? 'https://' : 'http://'
if (this.path && !this.path?.endsWith('/')) {
Expand All @@ -728,7 +735,7 @@ export class DDPClient extends EventEmitter<DDPClientEvents> {

try {
const response = await got(url, {
headers: this.headers,
headers: this.getHeadersWithDefaults(),
https: {
certificateAuthority: this.tlsOpts.ca,
key: this.tlsOpts.key,
Expand Down Expand Up @@ -769,7 +776,7 @@ export class DDPClient extends EventEmitter<DDPClientEvents> {

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

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

0 comments on commit 0bfe9f2

Please sign in to comment.