diff --git a/lib/core/renderer.js b/lib/core/renderer.js index 31cd8f3087..fff8b2ec70 100644 --- a/lib/core/renderer.js +++ b/lib/core/renderer.js @@ -10,7 +10,7 @@ import _ from 'lodash' import { join, resolve } from 'path' import fs from 'fs-extra' import { createBundleRenderer } from 'vue-server-renderer' -import { encodeHtml, getContext, setAnsiColors, isUrl } from 'utils' +import { encodeHtml, getContext, setAnsiColors } from 'utils' import Debug from 'debug' import connect from 'connect' @@ -205,8 +205,8 @@ export default class Renderer extends Tapable { next() }) - // Remove publicPath from requests when it is pointing to CDN - if (isUrl(this.options.build.publicPath)) { + // Remove publicPath from requests in production mode + if (!this.options.dev) { this.useMiddleware((req, res, next) => { if (req.url.indexOf(this.options.build.publicPath) === 0) { req.url = req.url.replace(this.options.build.publicPath, '/') @@ -239,6 +239,7 @@ export default class Renderer extends Tapable { // For dev they will be served with devMiddleware if (!this.options.dev) { this.useMiddleware(serveStatic(resolve(this.options.buildDir, 'dist'), { + index: false, // Don't serve index.html template maxAge: (this.options.dev ? 0 : '1y') // 1 year in production })) } diff --git a/lib/core/server.js b/lib/core/server.js index f0d71fa051..cec7a7f3b6 100644 --- a/lib/core/server.js +++ b/lib/core/server.js @@ -29,8 +29,7 @@ class Server { return this._ready } - this.render = this.nuxt.renderer.app - this.server = http.createServer(this.render) + this.server = http.createServer(this.nuxt.render) return this }