1
0
mirror of https://github.com/MisskeyIO/misskey synced 2024-12-15 15:18:18 +09:00

Merge pull request #70 from MisskeyIO/feature/show-hostname-in-header

Add x-worker-host header
This commit is contained in:
RyotaK 2023-03-07 20:10:43 +09:00 committed by GitHub
commit 8d1b05d69c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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);