-
Notifications
You must be signed in to change notification settings - Fork 0
fix: use HTTPS for API and WSS for WebSocket connections #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| # 生产环境配置 | ||
| # 注意:VITE_APP_URL 将在CI/CD构建时动态替换 | ||
| VITE_APP_URL=http://{{PRODUCTION_HOST}}:9009 | ||
| VITE_APP_URL=https://{{PRODUCTION_HOST}} | ||
| VUE_APP_TITLE=VocaTa | ||
| VITE_APP_ENV=production | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,5 +1,5 @@ | ||||||
| # 测试环境配置 | ||||||
| # 注意:VITE_APP_URL 将在CI/CD构建时动态替换 | ||||||
| VITE_APP_URL=http://{{STAGING_HOST}}:9009 | ||||||
| VITE_APP_URL=https://{{STAGING_HOST}} | ||||||
|
||||||
| VITE_APP_URL=https://{{STAGING_HOST}} | |
| VITE_APP_URL=https://{{STAGING_HOST}}:9009 |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -105,7 +105,11 @@ export class VocaTaWebSocketClient { | |||||||||||||||||||||
| return | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const wsUrl = `ws://${import.meta.env.VITE_APP_URL.replace('http://', '')}/ws/chat/${this.conversationUuid}?token=${encodeURIComponent(token)}` | ||||||||||||||||||||||
| const appUrl = import.meta.env.VITE_APP_URL || window.location.origin | ||||||||||||||||||||||
| const isSecure = appUrl.startsWith('https') | ||||||||||||||||||||||
| const wsProtocol = isSecure ? 'wss' : 'ws' | ||||||||||||||||||||||
| const host = appUrl.replace(/^https?:\/\//, '') | ||||||||||||||||||||||
|
Comment on lines
+108
to
+111
|
||||||||||||||||||||||
| const appUrl = import.meta.env.VITE_APP_URL || window.location.origin | |
| const isSecure = appUrl.startsWith('https') | |
| const wsProtocol = isSecure ? 'wss' : 'ws' | |
| const host = appUrl.replace(/^https?:\/\//, '') | |
| const hasWindow = typeof window !== 'undefined' | |
| const appUrl = hasWindow ? window.location.origin : import.meta.env.VITE_APP_URL | |
| const baseUrl = new URL(appUrl) | |
| const isSecure = hasWindow ? window.location.protocol === 'https:' : baseUrl.protocol === 'https:' | |
| const wsProtocol = isSecure ? 'wss' : 'ws' | |
| const host = baseUrl.host |
Copilot
AI
Apr 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logs part of the bearer token to the browser console. Even partial tokens can be sensitive when users share logs/screenshots or when console output is captured by monitoring tooling.
Recommend removing token logging or guarding it behind a strict development-only check (e.g., import.meta.env.DEV).
| console.log('🔌 尝试连接WebSocket:', wsUrl) | |
| console.log('🔐 使用Token:', token.substring(0, 20) + '...') | |
| console.log('🔌 尝试连接WebSocket:', `${wsProtocol}://${host}/ws/chat/${this.conversationUuid}`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change removes the explicit
:9009port fromVITE_APP_URL. If production traffic still reaches the backend on a non-default port (or if TLS termination isn’t providing HTTPS on 443), API and WebSocket connections built from this value will break.If the port is still required in some environments, keep it in the template (or introduce a dedicated port env var) so CI/CD substitution remains unambiguous.