diff options
Diffstat (limited to 'server.ts')
-rw-r--r-- | server.ts | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -1,4 +1,6 @@ | |||
1 | if ([ 'dev', 'test'].indexOf(process.env.NODE_ENV) !== -1) { | 1 | import { isTestInstance } from './server/helpers/core-utils' |
2 | |||
3 | if (isTestInstance()) { | ||
2 | require('source-map-support').install() | 4 | require('source-map-support').install() |
3 | } | 5 | } |
4 | 6 | ||
@@ -11,6 +13,7 @@ import * as http from 'http' | |||
11 | import * as morgan from 'morgan' | 13 | import * as morgan from 'morgan' |
12 | import * as path from 'path' | 14 | import * as path from 'path' |
13 | import * as bittorrentTracker from 'bittorrent-tracker' | 15 | import * as bittorrentTracker from 'bittorrent-tracker' |
16 | import * as cors from 'cors' | ||
14 | import { Server as WebSocketServer } from 'ws' | 17 | import { Server as WebSocketServer } from 'ws' |
15 | 18 | ||
16 | const TrackerServer = bittorrentTracker.Server | 19 | const TrackerServer = bittorrentTracker.Server |
@@ -56,6 +59,14 @@ import { apiRouter, clientsRouter, staticRouter } from './server/controllers' | |||
56 | 59 | ||
57 | // ----------- App ----------- | 60 | // ----------- App ----------- |
58 | 61 | ||
62 | // Enable cors for develop | ||
63 | if (isTestInstance()) { | ||
64 | app.use(cors({ | ||
65 | origin: 'http://localhost:3000', | ||
66 | credentials: true | ||
67 | })) | ||
68 | } | ||
69 | |||
59 | // For the logger | 70 | // For the logger |
60 | app.use(morgan('combined', { | 71 | app.use(morgan('combined', { |
61 | stream: { write: logger.info } | 72 | stream: { write: logger.info } |