Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 29 additions & 11 deletions client/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,41 @@ export default defineConfig({
// Required for SEP-1865 different-origin sandbox proxy
host: true,
proxy: {
"/api": {
// Sandbox proxy routes need special handling to prevent Vite HMR injection
// Without this, Vite injects its HMR client into the HTML, causing full-reload
// messages to be sent to the iframe, which breaks the sandbox architecture
"/api/mcp/sandbox-proxy": {
target: "http://localhost:6274",
changeOrigin: true,
secure: false,
ws: true,
configure: (proxy, _options) => {
proxy.on("error", (err, _req, _res) => {
// proxy error
});
proxy.on("proxyReq", (proxyReq, req, _res) => {
// proxy request
// selfHandleResponse prevents Vite from transforming the HTML response
selfHandleResponse: true,
configure: (proxy) => {
proxy.on("proxyRes", (proxyRes, req, res) => {
// Copy headers from proxy response
res.writeHead(proxyRes.statusCode || 200, proxyRes.headers);
// Pipe the response directly without Vite transformation
proxyRes.pipe(res);
});
proxy.on("proxyRes", (_proxyRes, _req, _res) => {
// no-op
},
},
"/api/apps/chatgpt/sandbox-proxy": {
target: "http://localhost:6274",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't look right?

changeOrigin: true,
selfHandleResponse: true,
configure: (proxy) => {
proxy.on("proxyRes", (proxyRes, req, res) => {
res.writeHead(proxyRes.statusCode || 200, proxyRes.headers);
proxyRes.pipe(res);
});
},
},
// General API proxy
"/api": {
target: "http://localhost:6274",
changeOrigin: true,
secure: false,
ws: true,
},
// Proxy WorkOS API calls during local dev to avoid browser CORS errors
"/user_management": {
target: "https://api.workos.com",
Expand Down