X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server.ts;h=c0e679b02539195cc97bb3583e58af9b8dda5cf3;hb=96bb360d9f4ad410ad753cb0c4d8d0a7bfd033f4;hp=5323bae2b423677bf3322fdf510485bfdd18e212;hpb=cff8b272b1631661b8d5f5f4b59bd534ad8c86ca;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server.ts b/server.ts index 5323bae2b..c0e679b02 100644 --- a/server.ts +++ b/server.ts @@ -12,7 +12,6 @@ import * as bodyParser from 'body-parser' import * as express from 'express' import * as http from 'http' import * as morgan from 'morgan' -import * as path from 'path' import * as bitTorrentTracker from 'bittorrent-tracker' import * as cors from 'cors' import { Server as WebSocketServer } from 'ws' @@ -95,7 +94,7 @@ if (isTestInstance()) { req.path.indexOf(STATIC_PATHS.WEBSEED) === -1 ) { return (cors({ - origin: 'http://localhost:3000', + origin: '*', exposedHeaders: 'Retry-After', credentials: true }))(req, res, next) @@ -156,20 +155,11 @@ app.use('/', activityPubRouter) app.use('/', feedsRouter) app.use('/', webfingerRouter) -// Client files -app.use('/', clientsRouter) - // Static files app.use('/', staticRouter) -// Always serve index client page (the client is a single page application, let it handle routing) -app.use('/*', function (req, res) { - if (req.accepts(ACCEPT_HEADERS) === 'html') { - return res.sendFile(path.join(__dirname, '../client/dist/index.html')) - } - - return res.status(404).end() -}) +// Client files, last valid routes! +app.use('/', clientsRouter) // ----------- Errors ----------- @@ -215,7 +205,8 @@ async function startApplication () { Redis.Instance.init() // Make server listening - server.listen(port, hostname) - logger.info('Server listening on %s:%d', hostname, port) - logger.info('Web server: %s', CONFIG.WEBSERVER.URL) + server.listen(port, hostname, () => { + logger.info('Server listening on %s:%d', hostname, port) + logger.info('Web server: %s', CONFIG.WEBSERVER.URL) + }) }