Skip to content

Commit f8e5a84

Browse files
feedback
1 parent db8adf5 commit f8e5a84

4 files changed

Lines changed: 37 additions & 92 deletions

File tree

packages/backend/src/api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class Api {
3535

3636
app.post('/api/sync-connection', this.syncConnection.bind(this));
3737
app.post('/api/index-repo', this.indexRepo.bind(this));
38-
app.post(`/api/experimental/add-github-repo`, this.addGithubRepo.bind(this));
38+
app.post(`/api/experimental/add-github-repo`, this.experimental_addGithubRepo.bind(this));
3939

4040
this.server = app.listen(PORT, () => {
4141
logger.info(`API server is running on port ${PORT}`);
@@ -95,7 +95,7 @@ export class Api {
9595
res.status(200).json({ jobId });
9696
}
9797

98-
private async addGithubRepo(req: Request, res: Response) {
98+
private async experimental_addGithubRepo(req: Request, res: Response) {
9999
const schema = z.object({
100100
owner: z.string(),
101101
repo: z.string(),

packages/web/src/app/[domain]/askgh/[owner]/[repo]/components/repoStatusDisplay.tsx

Lines changed: 0 additions & 90 deletions
This file was deleted.

packages/web/src/app/api/repo-status/[repoId]/route.ts renamed to packages/web/src/app/api/(server)/repo-status/[repoId]/route.ts

File renamed without changes.

packages/web/src/middleware.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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 middleware(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+
) {
15+
return NextResponse.next();
16+
}
17+
18+
const pathSegments = url.pathname.split('/').filter(Boolean);
19+
const currentDomain = pathSegments[0];
20+
21+
// If we're already on the correct domain path, allow
22+
if (currentDomain === SINGLE_TENANT_ORG_DOMAIN) {
23+
return NextResponse.next();
24+
}
25+
26+
url.pathname = `/${SINGLE_TENANT_ORG_DOMAIN}${pathSegments.length > 1 ? '/' + pathSegments.slice(1).join('/') : ''}`;
27+
return NextResponse.redirect(url);
28+
}
29+
30+
export const config = {
31+
// https://nextjs.org/docs/app/building-your-application/routing/middleware#matcher
32+
matcher: [
33+
'/((?!api|_next/static|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).*)',
34+
],
35+
}

0 commit comments

Comments
 (0)