From 5a14a7249b52fbbcb47db5ba7a366aabd3fd3a29 Mon Sep 17 00:00:00 2001 From: nkzawa Date: Sat, 8 Oct 2016 14:21:10 +0900 Subject: [PATCH] serve static dir --- server/index.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/server/index.js b/server/index.js index 6063c46143..a8e7dad74a 100644 --- a/server/index.js +++ b/server/index.js @@ -19,8 +19,13 @@ export default class Server { async start (port) { this.router.get('/_next/:path+', async (req, res, params) => { - const path = (params.path || []).join('/') - await this.serveStatic(req, res, path) + const p = resolve(__dirname, '../client', (params.path || []).join('/')) + await this.serveStatic(req, res, p) + }) + + this.router.get('/static/:path+', async (req, res, params) => { + const p = resolve(this.dir, 'static', (params.path || []).join('/')) + await this.serveStatic(req, res, p) }) this.router.get('/:path+.json', async (req, res, params) => { @@ -96,9 +101,8 @@ export default class Server { } serveStatic (req, res, path) { - const p = resolve(__dirname, '../client', path) return new Promise((resolve, reject) => { - send(req, p) + send(req, path) .on('error', (err) => { if ('ENOENT' === err.code) { this.render404(req, res).then(resolve, reject)