File tree Expand file tree Collapse file tree
[domain]/askgh/[owner]/[repo]/components
api/(server)/repo-status/[repoId] Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ( ) ,
Load Diff This file was deleted.
File renamed without changes.
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments