X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fcontrollers%2Fstatic.ts;h=75e30353c37a868df3398b482ae4abcf9ddb54d1;hb=be0f59b4eec3c2c4dcd151e2b174be39dff1568e;hp=df31c313455149b0345a71862bf98d89672709bf;hpb=c75937d04f0a45b1ba169d28d0854ad33cfee900;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/controllers/static.ts b/server/controllers/static.ts index df31c3134..75e30353c 100644 --- a/server/controllers/static.ts +++ b/server/controllers/static.ts @@ -1,5 +1,4 @@ import * as cors from 'cors' -import { createReadStream } from 'fs-extra' import * as express from 'express' import { CONFIG, ROUTE_CACHE_LIFETIME, STATIC_DOWNLOAD_PATHS, STATIC_MAX_AGE, STATIC_PATHS } from '../initializers' import { VideosPreviewCache } from '../lib/cache' @@ -10,6 +9,8 @@ import { VideosCaptionCache } from '../lib/cache/videos-caption-cache' import { UserModel } from '../models/account/user' import { VideoCommentModel } from '../models/video/video-comment' import { HttpNodeinfoDiasporaSoftwareNsSchema20 } from '../../shared/models/nodeinfo' +import { join } from 'path' +import { root } from '../helpers/core-utils' const packageJSON = require('../../../package.json') const staticRouter = express.Router() @@ -79,6 +80,21 @@ staticRouter.get('/robots.txt', } ) +// security.txt service +staticRouter.get('/security.txt', + (_, res: express.Response) => { + return res.redirect(301, '/.well-known/security.txt') + } +) + +staticRouter.get('/.well-known/security.txt', + asyncMiddleware(cacheRoute(ROUTE_CACHE_LIFETIME.SECURITYTXT)), + (_, res: express.Response) => { + res.type('text/plain') + return res.send(CONFIG.INSTANCE.SECURITYTXT + CONFIG.INSTANCE.SECURITYTXT_CONTACT) + } +) + // nodeinfo service staticRouter.use('/.well-known/nodeinfo', asyncMiddleware(cacheRoute(ROUTE_CACHE_LIFETIME.NODEINFO)), @@ -103,7 +119,8 @@ staticRouter.use('/.well-known/dnt-policy.txt', asyncMiddleware(cacheRoute(ROUTE_CACHE_LIFETIME.DNT_POLICY)), (_, res: express.Response) => { res.type('text/plain') - createReadStream('./server/static/dnt-policy/dnt-policy-1.0.txt').pipe(res) + + return res.sendFile(join(root(), 'dist/server/static/dnt-policy/dnt-policy-1.0.txt')) } )