Compare commits

...

1 Commits

Author SHA1 Message Date
Seth Shelnutt e2bb3a090e fix(site): proxy path-based workspace app routes in Vite dev server
During development, path-based workspace app URLs like
/@user/workspace.agent/apps/slug/ were not being proxied to the
backend. Vite's SPA fallback served index.html instead, requiring
developers to manually change the port to :3000.

Add proxy rules for /@ and /%40 prefixed paths that contain /apps/,
which are backend-handled workspace app routes. A bypass function
ensures other /@user/workspace paths continue to be served by Vite
as frontend routes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 04:16:24 +00:00
+30
View File
@@ -81,6 +81,36 @@ export default defineConfig({
secure: process.env.NODE_ENV === "production",
rewrite: (path) => path.replace(/\/+/g, "/"),
},
// Path-based workspace apps are served by the backend. Without
// these rules, Vite serves index.html (SPA fallback) instead
// of proxying to the Go server.
"/@": {
changeOrigin: true,
target: process.env.CODER_HOST || "http://localhost:3000",
secure: process.env.NODE_ENV === "production",
ws: true,
bypass: (req) => {
// Only proxy requests that contain /apps/ in the path,
// which are workspace app routes handled by the backend.
// Other /@user/workspace paths are frontend routes.
if (req.url?.includes("/apps/")) {
return undefined; // Proxy the request.
}
return false; // Skip proxy, let Vite handle it.
},
},
"/%40": {
changeOrigin: true,
target: process.env.CODER_HOST || "http://localhost:3000",
secure: process.env.NODE_ENV === "production",
ws: true,
bypass: (req) => {
if (req.url?.includes("/apps/")) {
return undefined;
}
return false;
},
},
"/api": {
ws: true,
changeOrigin: true,