Skip to content

Commit 6d122b5

Browse files
committed
fix(examples): accept any dev-server host (tailnets, tunnels, LAN)
Vite's default allowedHosts blocks requests arriving under a hostname it doesn't recognize (e.g. a tailnet or tunneled domain), which broke the hub examples and every Storybook dev server reached remotely. Allow any Host header on the example hubs and on all six Storybook configs, and keep ports non-strict so busy ports fall back to the next free one.
1 parent 285afc5 commit 6d122b5

8 files changed

Lines changed: 24 additions & 0 deletions

File tree

‎examples/minimal-vite-devframe-hub/vite.config.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import { minimalViteDevframeHub } from './src/minimal-vite-devframe-hub'
1212

1313
export default defineConfig({
1414
resolve: { alias },
15+
// Dev tooling reached from arbitrary hostnames (LAN IPs, tunnels, tailnets):
16+
// accept any Host header and fall back to the next free port when busy.
17+
server: { allowedHosts: true, strictPort: false },
1518
plugins: [
1619
UnoCSS(),
1720
minimalViteDevframeHub({

‎examples/storybook-hub/vite.config.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import { storybookHub } from './src/storybook-hub'
55

66
export default defineConfig({
77
resolve: { alias },
8+
// Dev tooling reached from arbitrary hostnames (LAN IPs, tunnels, tailnets):
9+
// accept any Host header and fall back to the next free port when busy.
10+
server: { allowedHosts: true, strictPort: false },
11+
preview: { allowedHosts: true, strictPort: false },
812
plugins: [
913
UnoCSS(),
1014
storybookHub(),

‎plugins/a11y/.storybook/main.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ const config: StorybookConfig = {
1616
return mergeConfig(config, {
1717
resolve: { alias },
1818
plugins: [UnoCSS()],
19+
// Dev tool reached from arbitrary hostnames (LAN IPs, tunnels,
20+
// tailnets), e.g. when iframed by the storybook-hub example.
21+
server: { allowedHosts: true },
1922
})
2023
},
2124
}

‎plugins/code-server/.storybook/main.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ const config: StorybookConfig = {
1010
viteFinal(viteConfig) {
1111
viteConfig.plugins ??= []
1212
viteConfig.plugins.push(UnoCSS())
13+
// Dev tool reached from arbitrary hostnames (LAN IPs, tunnels, tailnets),
14+
// e.g. when iframed by the storybook-hub example: accept any Host header.
15+
viteConfig.server = { ...viteConfig.server, allowedHosts: true }
1316
return viteConfig
1417
},
1518
}

‎plugins/git/.storybook/main.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ const config: StorybookConfig = {
1515
// own; the React plugin wires up the automatic runtime so `.tsx` stories
1616
// and views parse.
1717
viteConfig.plugins.push(react(), UnoCSS())
18+
// Dev tool reached from arbitrary hostnames (LAN IPs, tunnels, tailnets),
19+
// e.g. when iframed by the storybook-hub example: accept any Host header.
20+
viteConfig.server = { ...viteConfig.server, allowedHosts: true }
1821
return viteConfig
1922
},
2023
}

‎plugins/inspect/.storybook/main.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ const config: StorybookConfig = {
1616
return mergeConfig(config, {
1717
resolve: { alias },
1818
plugins: [vue(), UnoCSS()],
19+
// Dev tool reached from arbitrary hostnames (LAN IPs, tunnels,
20+
// tailnets), e.g. when iframed by the storybook-hub example.
21+
server: { allowedHosts: true },
1922
})
2023
},
2124
}

‎plugins/terminals/.storybook/main.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ const config: StorybookConfig = {
1919
return mergeConfig(config, {
2020
resolve: { alias },
2121
plugins: [svelte(), UnoCSS()],
22+
// Dev tool reached from arbitrary hostnames (LAN IPs, tunnels,
23+
// tailnets), e.g. when iframed by the storybook-hub example.
24+
server: { allowedHosts: true },
2225
})
2326
},
2427
}

‎storybook/.storybook/main.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ const config: StorybookConfig = {
3232
viteFinal(viteConfig) {
3333
viteConfig.plugins ??= []
3434
viteConfig.plugins.push(UnoCSS())
35+
// Dev tool reached from arbitrary hostnames (LAN IPs, tunnels, tailnets).
36+
viteConfig.server = { ...viteConfig.server, allowedHosts: true }
3537
return viteConfig
3638
},
3739
}

0 commit comments

Comments
 (0)