Skip to content

Conversation

sapphi-red
Copy link
Member

Description

Show the hosts in the certificate for HTTPS like below.
image

close #8200

@sapphi-red sapphi-red added the p2-to-be-discussed Enhancement under consideration (priority) label Jan 30, 2025

if (hostnameFromCert.length > 0) {
const existings = new Set([...local, ...network])
local.push(
Copy link
Member Author

@sapphi-red sapphi-red Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went with adding all of these to local so that Network: use --host to expose is shown when --host is not passed.
We can also hide hosts that resolves to addresses that are not loopback addresses when --host is not passed, but I felt that confusing.

@patak-dev patak-dev merged commit a5e306f into vitejs:main Feb 5, 2025
16 checks passed
@sapphi-red sapphi-red deleted the feat/show-hosts-in-cert-in-cli branch February 5, 2025 09:53
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Feb 7, 2025
| datasource | package | from  | to    |
| ---------- | ------- | ----- | ----- |
| npm        | vite    | 6.0.7 | 6.1.0 |


## [v6.1.0](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#610-2025-02-05)

-   refactor: deprecate `vite optimize` command ([#19348](vitejs/vite#19348)) ([6e0e3c0](vitejs/vite@6e0e3c0)), closes [#19348](vitejs/vite#19348)
-   feat: show hosts in cert in CLI ([#19317](vitejs/vite#19317)) ([a5e306f](vitejs/vite@a5e306f)), closes [#19317](vitejs/vite#19317)
-   feat: support for env var for defining allowed hosts ([#19325](vitejs/vite#19325)) ([4d88f6c](vitejs/vite@4d88f6c)), closes [#19325](vitejs/vite#19325)
-   feat: use native runtime to import the config ([#19178](vitejs/vite#19178)) ([7c2a794](vitejs/vite@7c2a794)), closes [#19178](vitejs/vite#19178)
-   fix: avoid builtStart during vite optimize ([#19356](vitejs/vite#19356)) ([fdb36e0](vitejs/vite@fdb36e0)), closes [#19356](vitejs/vite#19356)
-   fix(build): fix stale build manifest on watch rebuild ([#19361](vitejs/vite#19361)) ([fcd5785](vitejs/vite@fcd5785)), closes [#19361](vitejs/vite#19361)


## [v6.0.11](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small6011-2025-01-21-small)

-   fix: `preview.allowedHosts` with specific values was not respected ([#19246](vitejs/vite#19246)) ([aeb3ec8](vitejs/vite@aeb3ec8)), closes [#19246](vitejs/vite#19246)
-   fix: allow CORS from loopback addresses by default ([#19249](vitejs/vite#19249)) ([3d03899](vitejs/vite@3d03899)), closes [#19249](vitejs/vite#19249)


## [v6.0.10](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small6010-2025-01-20-small)

-   fix: try parse `server.origin` URL ([#19241](vitejs/vite#19241)) ([2495022](vitejs/vite@2495022)), closes [#19241](vitejs/vite#19241)


## [v6.0.9](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small609-2025-01-20-small)

-   fix!: check host header to prevent DNS rebinding attacks and introduce `server.allowedHosts` ([bd896fb](vitejs/vite@bd896fb))
-   fix!: default `server.cors: false` to disallow fetching from untrusted origins ([b09572a](vitejs/vite@b09572a))
-   fix: verify token for HMR WebSocket connection ([029dcd6](vitejs/vite@029dcd6))


## [v6.0.8](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small608-2025-01-20-small)

-   fix: avoid SSR HMR for HTML files ([#19193](vitejs/vite#19193)) ([3bd55bc](vitejs/vite@3bd55bc)), closes [#19193](vitejs/vite#19193)
-   fix: build time display 7m 60s ([#19108](vitejs/vite#19108)) ([cf0d2c8](vitejs/vite@cf0d2c8)), closes [#19108](vitejs/vite#19108)
-   fix: don't resolve URL starting with double slash ([#19059](vitejs/vite#19059)) ([35942cd](vitejs/vite@35942cd)), closes [#19059](vitejs/vite#19059)
-   fix: ensure `server.close()` only called once ([#19204](vitejs/vite#19204)) ([db81c2d](vitejs/vite@db81c2d)), closes [#19204](vitejs/vite#19204)
-   fix: resolve.conditions in ResolvedConfig was `defaultServerConditions` ([#19174](vitejs/vite#19174)) ([ad75c56](vitejs/vite@ad75c56)), closes [#19174](vitejs/vite#19174)
-   fix: tree shake stringified JSON imports ([#19189](vitejs/vite#19189)) ([f2aed62](vitejs/vite@f2aed62)), closes [#19189](vitejs/vite#19189)
-   fix: use shared sigterm callback ([#19203](vitejs/vite#19203)) ([47039f4](vitejs/vite@47039f4)), closes [#19203](vitejs/vite#19203)
-   fix(deps): update all non-major dependencies ([#19098](vitejs/vite#19098)) ([8639538](vitejs/vite@8639538)), closes [#19098](vitejs/vite#19098)
-   fix(optimizer): use correct default install state path for yarn PnP ([#19119](vitejs/vite#19119)) ([e690d8b](vitejs/vite@e690d8b)), closes [#19119](vitejs/vite#19119)
-   fix(types): improve `ESBuildOptions.include / exclude` type to allow `readonly (string | RegExp)[]`  ([ea53e70](vitejs/vite@ea53e70)), closes [#19146](vitejs/vite#19146)
-   chore(deps): update dependency pathe to v2 ([#19139](vitejs/vite#19139)) ([71506f0](vitejs/vite@71506f0)), closes [#19139](vitejs/vite#19139)
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Feb 7, 2025
| datasource | package | from  | to    |
| ---------- | ------- | ----- | ----- |
| npm        | vite    | 6.0.7 | 6.1.0 |


## [v6.1.0](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#610-2025-02-05)

-   refactor: deprecate `vite optimize` command ([#19348](vitejs/vite#19348)) ([6e0e3c0](vitejs/vite@6e0e3c0)), closes [#19348](vitejs/vite#19348)
-   feat: show hosts in cert in CLI ([#19317](vitejs/vite#19317)) ([a5e306f](vitejs/vite@a5e306f)), closes [#19317](vitejs/vite#19317)
-   feat: support for env var for defining allowed hosts ([#19325](vitejs/vite#19325)) ([4d88f6c](vitejs/vite@4d88f6c)), closes [#19325](vitejs/vite#19325)
-   feat: use native runtime to import the config ([#19178](vitejs/vite#19178)) ([7c2a794](vitejs/vite@7c2a794)), closes [#19178](vitejs/vite#19178)
-   fix: avoid builtStart during vite optimize ([#19356](vitejs/vite#19356)) ([fdb36e0](vitejs/vite@fdb36e0)), closes [#19356](vitejs/vite#19356)
-   fix(build): fix stale build manifest on watch rebuild ([#19361](vitejs/vite#19361)) ([fcd5785](vitejs/vite@fcd5785)), closes [#19361](vitejs/vite#19361)


## [v6.0.11](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small6011-2025-01-21-small)

-   fix: `preview.allowedHosts` with specific values was not respected ([#19246](vitejs/vite#19246)) ([aeb3ec8](vitejs/vite@aeb3ec8)), closes [#19246](vitejs/vite#19246)
-   fix: allow CORS from loopback addresses by default ([#19249](vitejs/vite#19249)) ([3d03899](vitejs/vite@3d03899)), closes [#19249](vitejs/vite#19249)


## [v6.0.10](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small6010-2025-01-20-small)

-   fix: try parse `server.origin` URL ([#19241](vitejs/vite#19241)) ([2495022](vitejs/vite@2495022)), closes [#19241](vitejs/vite#19241)


## [v6.0.9](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small609-2025-01-20-small)

-   fix!: check host header to prevent DNS rebinding attacks and introduce `server.allowedHosts` ([bd896fb](vitejs/vite@bd896fb))
-   fix!: default `server.cors: false` to disallow fetching from untrusted origins ([b09572a](vitejs/vite@b09572a))
-   fix: verify token for HMR WebSocket connection ([029dcd6](vitejs/vite@029dcd6))


## [v6.0.8](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small608-2025-01-20-small)

-   fix: avoid SSR HMR for HTML files ([#19193](vitejs/vite#19193)) ([3bd55bc](vitejs/vite@3bd55bc)), closes [#19193](vitejs/vite#19193)
-   fix: build time display 7m 60s ([#19108](vitejs/vite#19108)) ([cf0d2c8](vitejs/vite@cf0d2c8)), closes [#19108](vitejs/vite#19108)
-   fix: don't resolve URL starting with double slash ([#19059](vitejs/vite#19059)) ([35942cd](vitejs/vite@35942cd)), closes [#19059](vitejs/vite#19059)
-   fix: ensure `server.close()` only called once ([#19204](vitejs/vite#19204)) ([db81c2d](vitejs/vite@db81c2d)), closes [#19204](vitejs/vite#19204)
-   fix: resolve.conditions in ResolvedConfig was `defaultServerConditions` ([#19174](vitejs/vite#19174)) ([ad75c56](vitejs/vite@ad75c56)), closes [#19174](vitejs/vite#19174)
-   fix: tree shake stringified JSON imports ([#19189](vitejs/vite#19189)) ([f2aed62](vitejs/vite@f2aed62)), closes [#19189](vitejs/vite#19189)
-   fix: use shared sigterm callback ([#19203](vitejs/vite#19203)) ([47039f4](vitejs/vite@47039f4)), closes [#19203](vitejs/vite#19203)
-   fix(deps): update all non-major dependencies ([#19098](vitejs/vite#19098)) ([8639538](vitejs/vite@8639538)), closes [#19098](vitejs/vite#19098)
-   fix(optimizer): use correct default install state path for yarn PnP ([#19119](vitejs/vite#19119)) ([e690d8b](vitejs/vite@e690d8b)), closes [#19119](vitejs/vite#19119)
-   fix(types): improve `ESBuildOptions.include / exclude` type to allow `readonly (string | RegExp)[]`  ([ea53e70](vitejs/vite@ea53e70)), closes [#19146](vitejs/vite#19146)
-   chore(deps): update dependency pathe to v2 ([#19139](vitejs/vite#19139)) ([71506f0](vitejs/vite@71506f0)), closes [#19139](vitejs/vite#19139)
@Mrlilili
Copy link
Contributor

Mrlilili commented Feb 11, 2025

When I use vite-plugin-mkcert, this issue occurs,this change will have an expression different from the previous version.

server: {
    host: 'dev.aaaa.com',
    open: true
  }

Here, the host is configured as dev.aaaa.com. In previous versions, starting vite would automatically open https://dev.aaaa.com:5137/.
In the new version, it will open https://localhost:5173/.

To maintain consistency with the previous version, need to modify server.open in vite.conf.mts to https://dev.aaaa.com:5173/.

Can it be opened using the domain name of serve.host instead of https://localhost:5173/?


It seems to be the first domain automatically opened.

const url =
server.resolvedUrls?.local[0] ?? server.resolvedUrls?.network[0]

@sapphi-red
Copy link
Member Author

@Mrlilili Selecting a URL that includes server.host from server.resolvedUrls when opening a browser sounds good to me. Feel free to create a PR. I guess it's fine to introduce it in a minor.

@Mrlilili
Copy link
Contributor

Mrlilili commented Feb 13, 2025

@Mrlilili Selecting a URL that includes server.host from server.resolvedUrls when opening a browser sounds good to me. Feel free to create a PR. I guess it's fine to introduce it in a minor.


Ok, I submitted a PR, you can check it out.

#19414

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p2-to-be-discussed Enhancement under consideration (priority)

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

read certificate and show the correct domain when startup

3 participants