Commit Check
Issue Description
When creating a new channel on an HTTP (non-HTTPS) deployment, the EditChannelModal white-screens immediately on mount with:
TypeError: Cannot read properties of undefined (reading 'readText')
How to Reproduce
- Deploy new-api v0.12.0 on HTTP (e.g.
http://localhost:3000)
- Log in as admin
- Go to Channels page
- Click "New Channel" button
- Modal opens → white screen
Expected Behavior
Modal should open normally. Clipboard detection should be silently skipped on HTTP.
Root Cause
web/src/components/table/channels/modals/EditChannelModal.jsx (introduced in commit 670abee2):
// Line ~1315
navigator?.clipboard?.readText()?.then((text) => { ... }).catch(() => {});
navigator.clipboard is undefined in non-secure (HTTP) contexts. The optional chain ?.readText() correctly short-circuits and returns undefined, but then .then() is called on undefined → TypeError → white screen.
Suggested Fix
try {
- navigator?.clipboard?.readText()?.then((text) => {
- const parsed = parseChannelConnectionString(text);
- if (parsed) {
- setClipboardConfig(parsed);
- }
- }).catch(() => {});
+ if (navigator?.clipboard?.readText) {
+ navigator.clipboard.readText().then((text) => {
+ const parsed = parseChannelConnectionString(text);
+ if (parsed) {
+ setClipboardConfig(parsed);
+ }
+ }).catch(() => {});
+ }
} catch {}
Environment
- Version: v0.12.0
- Browser: Chrome 136
- Protocol: HTTP (non-HTTPS)
Commit Check
Issue Description
When creating a new channel on an HTTP (non-HTTPS) deployment, the EditChannelModal white-screens immediately on mount with:
How to Reproduce
http://localhost:3000)Expected Behavior
Modal should open normally. Clipboard detection should be silently skipped on HTTP.
Root Cause
web/src/components/table/channels/modals/EditChannelModal.jsx(introduced in commit670abee2):navigator.clipboardisundefinedin non-secure (HTTP) contexts. The optional chain?.readText()correctly short-circuits and returnsundefined, but then.then()is called onundefined→ TypeError → white screen.Suggested Fix
try { - navigator?.clipboard?.readText()?.then((text) => { - const parsed = parseChannelConnectionString(text); - if (parsed) { - setClipboardConfig(parsed); - } - }).catch(() => {}); + if (navigator?.clipboard?.readText) { + navigator.clipboard.readText().then((text) => { + const parsed = parseChannelConnectionString(text); + if (parsed) { + setClipboardConfig(parsed); + } + }).catch(() => {}); + } } catch {}Environment