Add x-worker-host header

This commit is contained in:
Ry0taK 2023-03-07 08:31:16 +00:00
parent 8ecd5d2a12
commit 7166195415
1 changed files with 7 additions and 0 deletions

View File

@ -1,4 +1,5 @@
import cluster from 'node:cluster'; import cluster from 'node:cluster';
import os from 'node:os';
import * as fs from 'node:fs'; import * as fs from 'node:fs';
import { Inject, Injectable, OnApplicationShutdown } from '@nestjs/common'; import { Inject, Injectable, OnApplicationShutdown } from '@nestjs/common';
import Fastify, { FastifyInstance } from 'fastify'; 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.apiServerService.createServer, { prefix: '/api' });
fastify.register(this.fileServerService.createServer); fastify.register(this.fileServerService.createServer);
fastify.register(this.activityPubServerService.createServer); fastify.register(this.activityPubServerService.createServer);