server.base

  • Type: string
  • Default: /
  • Version: >= 1.0.10

server.base is used to configure the base path of the server.

Example

By default, the base path of the server is /, and users can access index.html through http://localhost:3000.

If you want to access index.html through http://localhost:3000/foo/, you can change server.base to /foo.

export default {
  server: {
    base: '/foo',
  },
};

URL prefix of assets

By default, dev.assetPrefix and output.assetPrefix will read the value of server.base as the default value.

When server.base is /foo, the default resource URL loaded in the browser is as follows:

<script defer src="/foo/static/js/index.js"></script>

Then, index.html and static assets can be accessed through http://localhost:3000/foo/.

If you do not want to use this default behavior, you can override it by explicitly setting dev.assetPrefix / output.assetPrefix :

export default {
  dev: {
    assetPrefix: '/',
  },
  output: {
    assetPrefix: 'https://cdn.example.com/assets/',
  },
  server: {
    base: '/foo',
  },
};