@@ -502,7 +502,7 @@ def vite_config_template(
502502 force_full_reload : bool ,
503503 experimental_hmr : bool ,
504504 sourcemap : bool | Literal ["inline" , "hidden" ],
505- allowed_hosts : bool = False ,
505+ allowed_hosts : bool | list [ str ] = False ,
506506):
507507 """Template for vite.config.js.
508508
@@ -512,12 +512,17 @@ def vite_config_template(
512512 force_full_reload: Whether to force a full reload on changes.
513513 experimental_hmr: Whether to enable experimental HMR features.
514514 sourcemap: The sourcemap configuration.
515- allowed_hosts: Whether to allow all hosts in the Vite dev server .
515+ allowed_hosts: Allow all hosts (True), specific hosts (list of strings), or only localhost (False) .
516516
517517 Returns:
518518 Rendered vite.config.js content as string.
519519 """
520- allowed_hosts_line = "\n allowedHosts: true," if allowed_hosts else ""
520+ if allowed_hosts is True :
521+ allowed_hosts_line = "\n allowedHosts: true,"
522+ elif isinstance (allowed_hosts , list ) and allowed_hosts :
523+ allowed_hosts_line = f"\n allowedHosts: { json .dumps (allowed_hosts )} ,"
524+ else :
525+ allowed_hosts_line = ""
521526 return rf"""import {{ fileURLToPath, URL }} from "url";
522527import {{ reactRouter }} from "@react-router/dev/vite";
523528import {{ defineConfig }} from "vite";
0 commit comments