Skip to content

Commit 162b2e9

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

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-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
162+
your viteFinal configuration `.storybook/main.ts`
163+
164+
```typescript
165+
async viteFinal(config) {
166+
const { mergeConfig } = await import("vite");
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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
map $http_upgrade $connection_upgrade {
2+
default upgrade;
3+
'' close;
4+
}
5+
16
server {
27

38
include include.d/ssl.conf;
@@ -9,6 +14,11 @@ server {
914
proxy_set_header Host $host;
1015
proxy_set_header X-Real-IP $remote_addr;
1116
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
17+
18+
# WebSocket support for Vite-based Storybook
19+
proxy_set_header Upgrade $http_upgrade;
20+
proxy_set_header Connection $connection_upgrade;
21+
proxy_read_timeout 86400;
1222
}
1323

1424
location /__webpack-hmr {

0 commit comments

Comments
 (0)