mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-22 06:00:56 +02:00
🚫🔍 feat: disallow search indexing (#1409)
* feat: disallow search indexing * Update index.js * Update .env.example * added middleware
This commit is contained in:
parent
c3d5a08b26
commit
bd4d23d314
4 changed files with 18 additions and 0 deletions
|
@ -24,9 +24,12 @@ MONGO_URI=mongodb://127.0.0.1:27017/LibreChat
|
|||
DOMAIN_CLIENT=http://localhost:3080
|
||||
DOMAIN_SERVER=http://localhost:3080
|
||||
|
||||
NO_INDEX=true
|
||||
|
||||
#===============#
|
||||
# Debug Logging #
|
||||
#===============#
|
||||
|
||||
DEBUG_LOGGING=true
|
||||
DEBUG_CONSOLE=false
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ const errorController = require('./controllers/ErrorController');
|
|||
const configureSocialLogins = require('./socialLogins');
|
||||
const { connectDb, indexSync } = require('~/lib/db');
|
||||
const { logger } = require('~/config');
|
||||
const noIndex = require('./middleware/noIndex');
|
||||
|
||||
const paths = require('~/config/paths');
|
||||
const routes = require('./routes');
|
||||
|
@ -28,6 +29,7 @@ const startServer = async () => {
|
|||
app.locals.config = paths;
|
||||
|
||||
// Middleware
|
||||
app.use(noIndex);
|
||||
app.use(errorController);
|
||||
app.use(express.json({ limit: '3mb' }));
|
||||
app.use(mongoSanitize());
|
||||
|
|
|
@ -12,6 +12,7 @@ const concurrentLimiter = require('./concurrentLimiter');
|
|||
const validateMessageReq = require('./validateMessageReq');
|
||||
const buildEndpointOption = require('./buildEndpointOption');
|
||||
const validateRegistration = require('./validateRegistration');
|
||||
const noIndex = require('./noIndex');
|
||||
|
||||
module.exports = {
|
||||
...abortMiddleware,
|
||||
|
@ -28,4 +29,5 @@ module.exports = {
|
|||
validateMessageReq,
|
||||
buildEndpointOption,
|
||||
validateRegistration,
|
||||
noIndex,
|
||||
};
|
||||
|
|
11
api/server/middleware/noIndex.js
Normal file
11
api/server/middleware/noIndex.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
const noIndex = (req, res, next) => {
|
||||
const shouldNoIndex = process.env.NO_INDEX ? process.env.NO_INDEX === 'true' : true;
|
||||
|
||||
if (shouldNoIndex) {
|
||||
res.setHeader('X-Robots-Tag', 'noindex');
|
||||
}
|
||||
|
||||
next();
|
||||
};
|
||||
|
||||
module.exports = noIndex;
|
Loading…
Add table
Add a link
Reference in a new issue