Skip to content

Support Extracting Hostnames From Multiple Certificates #20681

@EmperorArthur

Description

@EmperorArthur

Description

As a corporate developer, I load in multiple certificates when using Vite, and would like automatic URL hostname detection to work the same as it does for a single certificate.

Node explicitly allows multiple certificates and keys to be used, and this seems like an arbitrary, undocumented, Vite limitation.

Suggested solution

The resolveServerUrls function handles a single certificate. The logic could easily be expanded to handle multiple certificates.

httpsOptions?.cert && !Array.isArray(httpsOptions.cert)

Alternative

Support more than one "host" in the server config section.

Adding custom host URLs involves writing a plugin with the following:

export function MyPlugin(): VitePlugin {
  return {
    name: "MultipleUrlPlugin",
    async configureServer(this: MinimalPluginContextWithoutEnvironment, server: ViteDevServer): Promise<void> {
      httpsServer.on('listening', () => {
        server.resolvedUrls = customResolveServerUrls(...)
      })
    }
  }
}

Additional context

Node v22 has some problems with multiple certificates, and can use PFX files as well as cert/key pairs. Bugs/Feature requests relating to those are outside the scope of this.

Validations

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions