fix(chat-deploy): fixed chat-deploy#981
Conversation
There was a problem hiding this comment.
Greptile Summary
This PR fixes a middleware routing issue that was preventing chat deployments from working correctly in self-hosted environments. The change modifies the middleware logic in apps/sim/middleware.ts by adding a !isCustomDomain condition to the existing self-hosted redirect check.
The root cause was that self-hosted deployments were incorrectly redirecting all root path requests (/) to workspace or login pages, including requests to chat subdomains. Chat subdomains need to serve their own chat interfaces, but the self-hosted redirect logic was intercepting these requests before they could be processed by the dedicated subdomain handling code.
The fix ensures that the self-hosted redirect behavior (lines 77+) only applies to the main domain by checking !isCustomDomain. This allows chat subdomains to be properly handled by the existing rewrite logic (lines 66-73) that serves chat functionality, while maintaining the intended redirect behavior for the main domain in self-hosted environments. The change preserves the separation between main domain functionality (workspace/login redirects) and subdomain functionality (chat interfaces).
Confidence score: 5/5
- This PR is safe to merge with minimal risk as it's a targeted bug fix with clear logic
- Score reflects the surgical nature of the change and clear understanding of the middleware flow
- No files require special attention as the change is isolated and well-understood
1 file reviewed, no comments
Summary
fixed chat-deploy for non-hosted environments
Type of Change
Testing
Tested manually.
Checklist