Skip to content

New 'server.allowedHosts' config does not allow the value 'true' #13342

Open
@st11x

Description

@st11x

Astro Info

Astro                    v5.4.1
Node                     v22.4.1
System                   Linux (x64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

I created a new project using pnpm create astro@latest with the basic, minimal starter template. Then I changed the astro.config.mjs to:

// @ts-check
import { defineConfig } from "astro/config";

// https://astro.build/config
export default defineConfig({
    server: {
        allowedHosts: true,
    },
});

Now even astro info fails with

> [email protected] astro /app/projects/astro
> astro info

[config] Astro found issue(s) with your configuration:

! server.allowedHosts: Did not match union.
  > Expected type { 0: string } |
  > Received [ true ]

and starting the dev server fails with

dev-1  |
dev-1  | > [email protected] dev /app/projects/astro
dev-1  | > astro dev --host
dev-1  |
dev-1  | [config] Astro found issue(s) with your configuration:
dev-1  |
dev-1  | ! server.allowedHosts: Did not match union.
dev-1  |   > Expected type { 0: string } |
dev-1  |   > Received [ true ]
dev-1  |

The workaround is to use the --allowed-hosts CLI parameter.

What's the expected result?

The astro info and astro dev commands should not error out. According to Vite's documentation as linked in the release notes, you are allowed to specify the boolean value true.

Link to Minimal Reproducible Example

https://zzmivbmxlngithub-dieg--4321--31ca1d38.local-corp.webcontainer.io

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P3: minor bugAn edge case that only affects very specific usage (priority)pkg: astroRelated to the core `astro` package (scope)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions