fix(kimi-web): set rewriteWsOrigin for dev and preview proxy#1158
fix(kimi-web): set rewriteWsOrigin for dev and preview proxy#1158Sepush wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 4eeb939 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ae84677cb9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Set Vite's rewriteWsOrigin option so the WebSocket Origin header is rewritten to match the upstream server target during local development. This fixes 403 handshake failures when the browser opens the dev UI on localhost:5175 while the server binds 127.0.0.1:58627.
ae84677 to
4eeb939
Compare
|
@chatgpt-codex-connector Thanks for the review. I've retargeted the changeset from "@moonshot-ai/kimi-web" to "@moonshot-ai/kimi-code" as per the repository's publishing strategy. |
|
You have reached your Codex usage limits. You can see your limits in the Codex usage dashboard. |
Related Issue
Closes #1157
Problem
When running
pnpm dev:webandpnpm dev:server, the browser opens the web UI athttp://localhost:5175while the local server binds127.0.0.1:58627. The WebSocket upgrade request carriesOrigin: http://localhost:5175, but Vite's dev proxy rewrites theHostheader to127.0.0.1:58627. The server's Origin check treatslocalhostand127.0.0.1as different origins and rejects the handshake with 403, causing the web UI to show a persistent "WebSocket error".What changed
Set Vite's
rewriteWsOrigin: trueoption on the/api/v1proxy for both dev and preview modes. This tells Vite to rewrite the WebSocketOriginheader to match the upstream target origin during the upgrade handshake, so the server's same-origin check passes.This uses the built-in Vite option added in vitejs/vite#16558 rather than a custom
configure+proxyReqWshandler.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.