Skip to content

Commit 48e595d

Browse files
Gestion de la route '/robots.txt'
1 parent 0a0aad3 commit 48e595d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

index.mjs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ app.use(session({
3030
app.use('*', (req, res, next) => {
3131
console.log('*****************************');
3232
console.log('*** New request ***');
33+
console.log(`*** Client IP: ${req.headers['x-forwarded-for'] || req.socket.remoteAddress} ***`);
34+
console.log(`*** Client domain: ${req.hostname}:${req.socket.localPort} ***`);
3335
console.log(`*** Received url: ${req.url} ***`);
3436
console.log(`*** Requested url: ${req.query?.url ?? req.originalUrl} ***`);
3537

@@ -58,9 +60,14 @@ app.get(entryEndpoint, async (req, res) => {
5860
getAndSendData(res, targetUrl);
5961
});
6062

63+
app.get('/robots.txt', (_req, res) => {
64+
res.type('text/plain');
65+
res.send('User-agent: *\nDisallow: /');
66+
});
67+
6168
app.get('/', (_req, res) => {
6269
const welcomeMsg = "Bienvenue sur smart-proxy ! \nAjouter le paramètre '/proxy?url=http...' à la route courante en completant l'URL";
63-
const welcomeMsg_EN= "Welcome to smart-proxy! \nAdd the query parameter '/proxy?url=http...' to the current route by completing the URL";
70+
const welcomeMsg_EN = "Welcome to smart-proxy! \nAdd the query parameter '/proxy?url=http...' to the current route by completing the URL";
6471
res.status(200).send(welcomeMsg.concat(' /\n\n').concat(welcomeMsg_EN));
6572
});
6673

@@ -83,7 +90,7 @@ app.listen(port, () => {
8390
//#region Helpers
8491

8592
async function getAndSendData(res, targetUrl) {
86-
console.log(`*** target url: ${targetUrl}`);
93+
console.log(`*** target url: ${targetUrl} ***`);
8794
console.log('*****************************');
8895

8996
try {

0 commit comments

Comments
 (0)