From 716619541518e8f251f47b7bdfb655e6874e88c1 Mon Sep 17 00:00:00 2001 From: Ry0taK <49341894+Ry0taK@users.noreply.github.com> Date: Tue, 7 Mar 2023 08:31:16 +0000 Subject: [PATCH] Add x-worker-host header --- packages/backend/src/server/ServerService.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/backend/src/server/ServerService.ts b/packages/backend/src/server/ServerService.ts index e61383468c..1c5ce7f2db 100644 --- a/packages/backend/src/server/ServerService.ts +++ b/packages/backend/src/server/ServerService.ts @@ -1,4 +1,5 @@ import cluster from 'node:cluster'; +import os from 'node:os'; import * as fs from 'node:fs'; import { Inject, Injectable, OnApplicationShutdown } from '@nestjs/common'; import Fastify, { FastifyInstance } from 'fastify'; @@ -71,6 +72,12 @@ export class ServerService implements OnApplicationShutdown { }); } + const hostname = os.hostname(); + fastify.addHook('onRequest', (request, reply, done) => { + reply.header('x-worker-host', hostname); + done(); + }); + fastify.register(this.apiServerService.createServer, { prefix: '/api' }); fastify.register(this.fileServerService.createServer); fastify.register(this.activityPubServerService.createServer);