https

  • Type: import('https').ServerOptions
  • Default: undefined

After configuring this option, you can enable HTTPS Server, and disabling the HTTP Server.

HTTP:

> Local: http://localhost:8080/
  > Network: http://192.168.0.1:8080/

HTTPS:

> Local: https://localhost:8080/
  > Network: https://192.168.0.1:8080/

Set Certificate

You can manually pass in the certificate and the private key required in the server.https option. This parameter will be directly passed to the createServer method of the https module in Node.js.

For details, please refer to https.createServer.

import fs from 'node:fs';

export default {
  server: {
    https: {
      key: fs.readFileSync('certificates/private.pem'),
      cert: fs.readFileSync('certificates/public.pem'),
    },
  },
};

The certificates used for local development are typically generated using mkcert. Please read "How to use HTTPS for local development" to learn how to use it.

ON THIS PAGE