Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions api/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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());
Expand Down
2 changes: 2 additions & 0 deletions api/server/middleware/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -28,4 +29,5 @@ module.exports = {
validateMessageReq,
buildEndpointOption,
validateRegistration,
noIndex,
};
11 changes: 11 additions & 0 deletions api/server/middleware/noIndex.js
Original file line number Diff line number Diff line change
@@ -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;