Skip to content

bug: Vite 6.x blocks custom domains - missing allowedHosts configuration #43

Closed

Description

@vybe

Summary

When accessing the Trinity frontend via a custom domain (e.g., trinity.example.com), Vite 6.x blocks the request with the error: "Blocked request. This host is not allowed." This is due to Vite 6.x's new security feature requiring explicit allowedHosts configuration. The frontend is inaccessible via custom domains until this is fixed.

Component

Frontend / Vite Configuration

Priority

P1 - Major feature broken (frontend inaccessible via custom domains)

Error

Blocked request. This host ("trinity.example.com") is not allowed.
To allow this host, add "trinity.example.com" to `server.allowedHosts` in vite.config.js.

Location

  • File: src/frontend/vite.config.js
  • Line: N/A (missing configuration)
  • Function/Class: server config block

Root Cause

Vite 6.x introduced stricter host checking as a security measure. The current vite.config.js does not include the allowedHosts configuration, causing Vite to block requests from any host other than localhost.

Reference: https://vite.dev/config/server-options.html#server-allowedhosts

Reproduction Steps

  1. Deploy Trinity to a server
  2. Configure a custom domain pointing to the Trinity frontend (e.g., via reverse proxy or DNS)
  3. Access the frontend via the custom domain
  4. Observe the "Blocked request" error

Suggested Fix

Add allowedHosts to the server configuration in vite.config.js:

export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src'),
    },
  },
  server: {
    port: 80,
    // Allow all hosts since Trinity is typically behind a reverse proxy
    // that handles host validation
    allowedHosts: true,
    proxy: {
      // ... existing proxy config
    }
  }
})

Alternatively, for more restrictive environments, use an environment variable:

server: {
  allowedHosts: process.env.VITE_ALLOWED_HOSTS?.split(',') || true,
  // ...
}

Environment

  • Trinity version: 281ee77
  • Vite version: ^6.0.6
  • @vitejs/plugin-vue: ^5.2.1

Related

Activity

  1. vybe commented on Feb 24, 2026

    @vybe
    ContributorAuthor

    Fixed in vite.config.js by adding allowedHosts: true to the server configuration.

    Change: src/frontend/vite.config.js:17-18

    // Allow all hosts - Trinity runs behind a reverse proxy that handles host validation
    allowedHosts: true,

    This allows Vite 6.x to accept requests from custom domains. The security consideration noted in Vite docs is mitigated by Trinity's architecture - the Vite dev server runs inside a Docker container behind nginx, which handles host validation at the reverse proxy level.

  2. added a commit that references this issue on Feb 24, 2026
    2ee530f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority-p1type-bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions