Skip to content

Dev server startup message shows http:// when HTTPS is configured #638

@torleifhalseth

Description

@torleifhalseth

When running sanity dev with HTTPS configured via vite.server.https in sanity.cli.ts, the startup message incorrectly shows:

│ Sanity Studio using vite@x.x.x ready in XXms and running at **http://**localhost:3333/

The server is actually running on HTTPS, so the URL should use https://.

Configuration

  // sanity.cli.ts
  export default defineCliConfig({
    vite: {
      server: {
        https: {
          key: "path/to/key.pem",
          cert: "path/to/cert.pem",
        },
      },
    },
  });

Suggested fix

In packages/sanity/src/_internal/cli/actions/dev/devAction.ts, the URL protocol is hardcoded as http://:

  const url = `http://${httpHost || 'localhost'}:${port}${config.basePath}`

It should check the Vite server config:

  - const url = `http://${httpHost || 'localhost'}:${port}${config.basePath}`
  + const protocol = server.config.server.https ? 'https' : 'http'
  + const url = `${protocol}://${httpHost || 'localhost'}:${port}${config.basePath}`

The same issue exists in getDashboardAppURL where http:// is also hardcoded.

Versions

  • sanity: 5.7.0
  • vite: 7.3.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions