Skip to content

Commit cd56d3b

Browse files
committed
Add WebSocket support in storybook image
1 parent 8b01966 commit cd56d3b

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,24 @@ environment:
158158
NGINX_PROXY_PASS: http://app:6006
159159
```
160160

161+
If your're using Vite-based Storybook, you need to add the following lines to your viteFinal configuration `.storybook/main.ts`
162+
163+
```typescript
164+
async viteFinal(config) {
165+
const { mergeConfig } = await import("vite");
166+
167+
return mergeConfig(config, {
168+
// Existing config...
169+
server: {
170+
hmr: {
171+
clientPort: 443,
172+
protocol: "wss",
173+
},
174+
},
175+
});
176+
},
177+
```
178+
161179
### Drupal
162180

163181
Drupal is a configuration that forwards PHP-FPM requests to a Drupal

context/storybook/etc/nginx/templates/default.conf.template

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ server {
99
proxy_set_header Host $host;
1010
proxy_set_header X-Real-IP $remote_addr;
1111
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
12+
13+
# WebSocket support for Vite-based Storybook
14+
proxy_set_header Upgrade $http_upgrade;
15+
proxy_set_header Connection "Upgrade";
16+
proxy_read_timeout 86400;
1217
}
1318

1419
location /__webpack-hmr {

0 commit comments

Comments
 (0)