Skip to content

Commit c0653cf

Browse files
fix(web): Fix issue with anonymous access (#984)
* fix * changelog
1 parent 0504da2 commit c0653cf

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
- Fixed issue where users would not be redirected to the homepage when clicking "continue with guest". [#984](https://github.com/sourcebot-dev/sourcebot/pull/984)
12+
1013
### Changed
1114
- Increased pagination limit to 1000 for bitbucket data center requests. [#981](https://github.com/sourcebot-dev/sourcebot/pull/981)
1215

packages/web/src/proxy.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { NextResponse } from 'next/server'
2+
import type { NextRequest } from 'next/server'
3+
import { SINGLE_TENANT_ORG_DOMAIN } from '@/lib/constants'
4+
5+
export async function proxy(request: NextRequest) {
6+
const url = request.nextUrl.clone();
7+
8+
if (
9+
url.pathname.startsWith('/login') ||
10+
url.pathname.startsWith('/redeem') ||
11+
url.pathname.startsWith('/signup') ||
12+
url.pathname.startsWith('/invite') ||
13+
url.pathname.startsWith('/onboard') ||
14+
url.pathname.startsWith('/oauth')
15+
) {
16+
return NextResponse.next();
17+
}
18+
19+
const pathSegments = url.pathname.split('/').filter(Boolean);
20+
const currentDomain = pathSegments[0];
21+
22+
// If we're already on the correct domain path, allow
23+
if (currentDomain === SINGLE_TENANT_ORG_DOMAIN) {
24+
return NextResponse.next();
25+
}
26+
27+
url.pathname = `/${SINGLE_TENANT_ORG_DOMAIN}${pathSegments.length > 1 ? '/' + pathSegments.slice(1).join('/') : ''}`;
28+
return NextResponse.redirect(url);
29+
}
30+
31+
export const config = {
32+
// https://nextjs.org/docs/app/building-your-application/routing/middleware#matcher
33+
matcher: [
34+
'/((?!api|_next/static|.well-known/oauth-authorization-server|.well-known/oauth-protected-resource|ingest|_next/image|favicon.ico|sitemap.xml|robots.txt|manifest.json|logo_192.png|logo_512.png|sb_logo_light_large.png|arrow.png|placeholder_avatar.png|sb_logo_dark_small.png|sb_logo_light_small.png).*)',
35+
],
36+
}

0 commit comments

Comments
 (0)