Skip to content

read certificate and show the correct domain when startup #8200

@michaelalhilly

Description

@michaelalhilly

Describe the bug

I'm trying to serve a Vue.js website from a Docker container using a custom domain and SSL cert. It looks like Vite is not serving the SSL cert and the browser is blocking the site with the error: NET::ERR_CERT_AUTHORITY_INVALID. This is because the browser is not receiving the provided SSL cert and is using the browser default example.org self signed cert.

This is currently working with Vue CLI using the same Docker image and run options.

Here are my Vite server settings:

host: '0.0.0.0',
port: 443,
https: {
  key: readFileSync(ssl_key),
  cert: readFileSync(ssl_cert)
},
proxy: {
  '/socket.io': {
    target: 'ws://mydomain.test',
    ws: true
  }
}

Server terminal output:

vite v2.9.9 dev server running at:

> Local:    https://localhost:443/
> Network:  https://172.17.0.2:443/

This is working with Vue CLI using the following:

port: 443,
host: '0.0.0.0',
https: true,
key: readFileSync(ssl_key),
cert: readFileSync(ssl_cert),
public: 'mydomain.test'

Vue CLI server terminal output:

App running at:
- Local:   https://localhost:443/ 
- Network: https://mydomain.test/

Is there a way to change "Network" in Vite as we can in Vue CLI?

Reproduction

https://github.com/michaelalhilly/ViteCustomDomain

System Info

System:
    OS: Linux 5.10 Debian GNU/Linux 10 (buster) 10 (buster)
    CPU: (6) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Memory: 6.78 GB / 7.77 GB
    Container: Yes
    Shell: 5.0.3 - /bin/bash
  Binaries:
    Node: 16.15.0 - /usr/local/bin/node
    Yarn: 1.22.18 - /usr/local/bin/yarn
    npm: 8.5.5 - /usr/local/bin/npm
  npmPackages:
    @vitejs/plugin-vue: ^2.3.1 => 2.3.3 
    vite: ^2.9.5 => 2.9.9

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions