mirror of https://github.com/Chocobozzz/PeerTube
Stop indexing /about/peertube
parent
32e06ca4de
commit
42cc1887af
|
@ -5,12 +5,12 @@ import { join } from 'path'
|
|||
import { logger } from '@server/helpers/logger'
|
||||
import { CONFIG } from '@server/initializers/config'
|
||||
import { Hooks } from '@server/lib/plugins/hooks'
|
||||
import { HttpStatusCode } from '@shared/models'
|
||||
import { buildFileLocale, getCompleteLocale, is18nLocale, LOCALE_FILES } from '@shared/core-utils/i18n'
|
||||
import { HttpStatusCode } from '@shared/models'
|
||||
import { root } from '../helpers/core-utils'
|
||||
import { STATIC_MAX_AGE } from '../initializers/constants'
|
||||
import { ClientHtml, sendHTML, serveIndexHTML } from '../lib/client-html'
|
||||
import { asyncMiddleware, embedCSP } from '../middlewares'
|
||||
import { asyncMiddleware, disableRobots, embedCSP } from '../middlewares'
|
||||
|
||||
const clientsRouter = express.Router()
|
||||
|
||||
|
@ -81,6 +81,12 @@ clientsRouter.use('/client/*', (req: express.Request, res: express.Response) =>
|
|||
res.status(HttpStatusCode.NOT_FOUND_404).end()
|
||||
})
|
||||
|
||||
// No index exceptions
|
||||
clientsRouter.all('/about/peertube',
|
||||
disableRobots,
|
||||
asyncMiddleware(serveIndexHTML)
|
||||
)
|
||||
|
||||
// Always serve index client page (the client is a single page application, let it handle routing)
|
||||
// Try to provide the right language index.html
|
||||
clientsRouter.use('/(:language)?', asyncMiddleware(serveIndexHTML))
|
||||
|
|
|
@ -69,6 +69,7 @@ staticRouter.get('/robots.txt',
|
|||
cacheRoute(ROUTE_CACHE_LIFETIME.ROBOTS),
|
||||
(_, res: express.Response) => {
|
||||
res.type('text/plain')
|
||||
|
||||
return res.send(CONFIG.INSTANCE.ROBOTS)
|
||||
}
|
||||
)
|
||||
|
|
|
@ -4,6 +4,7 @@ export * from './activitypub'
|
|||
export * from './async'
|
||||
export * from './auth'
|
||||
export * from './pagination'
|
||||
export * from './robots'
|
||||
export * from './servers'
|
||||
export * from './sort'
|
||||
export * from './user-right'
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
import express from 'express'
|
||||
|
||||
function disableRobots (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||
res.setHeader('X-Robots-Tag', 'noindex')
|
||||
|
||||
return next()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
disableRobots
|
||||
}
|
|
@ -482,6 +482,16 @@ describe('Test a client controllers', function () {
|
|||
}
|
||||
}
|
||||
})
|
||||
|
||||
it('Should add noindex header for some paths', async function () {
|
||||
const paths = [ '/about/peertube' ]
|
||||
|
||||
for (const path of paths) {
|
||||
const { headers } = await makeHTMLRequest(servers[0].url, path)
|
||||
|
||||
expect(headers['x-robots-tag']).to.equal('noindex')
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('Embed HTML', function () {
|
||||
|
|
Loading…
Reference in New Issue