Skip to content
This repository has been archived by the owner on Mar 10, 2024. It is now read-only.

Commit

Permalink
chore: prevent robots from crawling API (#1982)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmarshall authored Nov 27, 2023
1 parent f346cde commit c8d5362
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions apps/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import cors from 'cors';
import type { NextFunction, Request, Response } from 'express';
import express from 'express';
import promBundle from 'express-prom-bundle';
import robots from 'express-robots-txt';
import pinoHttp from 'pino-http';
import { v4 as uuidv4 } from 'uuid';
import { getDependencyContainer } from './dependency_container';
Expand All @@ -19,6 +20,13 @@ if (process.env.GLOBAL_AGENT_HTTP_PROXY) {
require('@supaglue/schemas/proxy.bootstrap');
}

app.use(
robots({
UserAgent: '*',
Disallow: '/',
})
);

app.use(
promBundle({
includeMethod: true,
Expand Down
1 change: 1 addition & 0 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"express": ">=5.0.0-beta.1",
"express-openapi-validator": "^5.0.2",
"express-prom-bundle": "^6.6.0",
"express-robots-txt": "^1.0.0",
"json-schema-traverse": "^1.0.0",
"jsonwebtoken": "^9.0.2",
"jwks-rsa": "^3.1.0",
Expand Down
1 change: 1 addition & 0 deletions apps/api/types/express-robots-txt.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module 'express-robots-txt';
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8505,6 +8505,7 @@ __metadata:
express: ">=5.0.0-beta.1"
express-openapi-validator: ^5.0.2
express-prom-bundle: ^6.6.0
express-robots-txt: ^1.0.0
json-schema-traverse: ^1.0.0
jsonwebtoken: ^9.0.2
jwks-rsa: ^3.1.0
Expand Down Expand Up @@ -12608,6 +12609,15 @@ __metadata:
languageName: node
linkType: hard

"express-robots-txt@npm:^1.0.0":
version: 1.0.0
resolution: "express-robots-txt@npm:1.0.0"
peerDependencies:
express: ^4.12.1
checksum: 8ee6e2a076bb7c06e59c01201ce3a789e31b1d1e938792d835538bf89337f3957baaab62ed5d045bb22724edebaaabcd2cf8974afb5fe3d056555a79da83846b
languageName: node
linkType: hard

"express@npm:>=5.0.0-beta.1":
version: 5.0.0-beta.1
resolution: "express@npm:5.0.0-beta.1"
Expand Down

0 comments on commit c8d5362

Please sign in to comment.