mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-18 23:35:25 +00:00
Sourcebot V4 introduces authentication, performance improvements and code navigation. Checkout the [migration guide](https://docs.sourcebot.dev/self-hosting/upgrade/v3-to-v4-guide) for information on upgrading your instance to v4. ### Changed - [**Breaking Change**] Authentication is now required by default. Notes: - When setting up your instance, email / password login will be the default authentication provider. - The first user that logs into the instance is given the `owner` role. ([docs](https://docs.sourcebot.dev/docs/more/roles-and-permissions)). - Subsequent users can request to join the instance. The `owner` can approve / deny requests to join the instance via `Settings` > `Members` > `Pending Requests`. - If a user is approved to join the instance, they are given the `member` role. - Additional login providers, including email links and SSO, can be configured with additional environment variables. ([docs](https://docs.sourcebot.dev/self-hosting/configuration/authentication)). - Clicking on a search result now takes you to the `/browse` view. Files can still be previewed by clicking the "Preview" button or holding `Cmd` / `Ctrl` when clicking on a search result. [#315](https://github.com/sourcebot-dev/sourcebot/pull/315) ### Added - [Sourcebot EE] Added search-based code navigation, allowing you to jump between symbol definition and references when viewing source files. [Read the documentation](https://docs.sourcebot.dev/docs/search/code-navigation). [#315](https://github.com/sourcebot-dev/sourcebot/pull/315) - Added collapsible filter panel. [#315](https://github.com/sourcebot-dev/sourcebot/pull/315) ### Fixed - Improved scroll performance for large numbers of search results. [#315](https://github.com/sourcebot-dev/sourcebot/pull/315)
34 lines
1.2 KiB
TypeScript
34 lines
1.2 KiB
TypeScript
import { NextResponse } from 'next/server'
|
|
import type { NextRequest } from 'next/server'
|
|
import { env } from './env.mjs'
|
|
import { SINGLE_TENANT_ORG_DOMAIN } from '@/lib/constants'
|
|
|
|
export async function middleware(request: NextRequest) {
|
|
const url = request.nextUrl.clone();
|
|
|
|
if (env.SOURCEBOT_TENANCY_MODE !== 'single') {
|
|
return NextResponse.next();
|
|
}
|
|
|
|
if (url.pathname.startsWith('/login') || url.pathname.startsWith('/redeem')) {
|
|
return NextResponse.next();
|
|
}
|
|
|
|
const pathSegments = url.pathname.split('/').filter(Boolean);
|
|
const currentDomain = pathSegments[0];
|
|
|
|
// If we're already on the correct domain path, allow
|
|
if (currentDomain === SINGLE_TENANT_ORG_DOMAIN) {
|
|
return NextResponse.next();
|
|
}
|
|
|
|
url.pathname = `/${SINGLE_TENANT_ORG_DOMAIN}${pathSegments.length > 1 ? '/' + pathSegments.slice(1).join('/') : ''}`;
|
|
return NextResponse.redirect(url);
|
|
}
|
|
|
|
export const config = {
|
|
// https://nextjs.org/docs/app/building-your-application/routing/middleware#matcher
|
|
matcher: [
|
|
'/((?!api|_next/static|ingest|_next/image|favicon.ico|sitemap.xml|robots.txt|sb_logo_light_large.png|arrow.png|placeholder_avatar.png).*)',
|
|
],
|
|
}
|