set X-Robots-Tag to disable indexing API endpoints
This commit is contained in:
@@ -148,6 +148,10 @@ export class ApiCallService implements OnApplicationShutdown {
|
||||
request: FastifyRequest<{ Body: Record<string, unknown> | undefined, Querystring: Record<string, unknown> }>,
|
||||
reply: FastifyReply,
|
||||
): void {
|
||||
// Tell crawlers not to index API endpoints.
|
||||
// https://developers.google.com/search/docs/crawling-indexing/block-indexing
|
||||
reply.header('X-Robots-Tag', 'noindex');
|
||||
|
||||
const body = request.method === 'GET'
|
||||
? request.query
|
||||
: request.body;
|
||||
|
||||
@@ -71,6 +71,13 @@ export class MastodonApiServerService {
|
||||
done();
|
||||
});
|
||||
|
||||
// Tell crawlers not to index API endpoints.
|
||||
// https://developers.google.com/search/docs/crawling-indexing/block-indexing
|
||||
fastify.addHook('onRequest', (request, reply, done) => {
|
||||
reply.header('X-Robots-Tag', 'noindex');
|
||||
done();
|
||||
});
|
||||
|
||||
// External endpoints
|
||||
this.apiAccountMastodon.register(fastify);
|
||||
this.apiAppsMastodon.register(fastify);
|
||||
|
||||
Reference in New Issue
Block a user