Skip to content

Commit ab213ca

Browse files
committed
Server-side API
1 parent 7a8509d commit ab213ca

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/app/api/releases/route.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import {NextResponse} from 'next/server';
2+
3+
// This endpoint proxies the release registry to not require access to another domain
4+
// when visiting sourcegraph.com/docs. This might help some customers with strict firewalls.
5+
export async function GET() {
6+
const res = await fetch(
7+
'https://releaseregistry.sourcegraph.com/v1/releases/sourcegraph',
8+
{next: {revalidate: 300}}
9+
);
10+
11+
if (!res.ok) {
12+
return NextResponse.json(
13+
{error: 'Failed to fetch releases'},
14+
{status: 500}
15+
);
16+
}
17+
18+
const data = await res.json();
19+
return NextResponse.json(data);
20+
}

src/components/ReleasesTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export function SupportedReleasesTable() {
6262
const [error, setError] = useState<string | null>(null);
6363

6464
useEffect(() => {
65-
fetch('https://releaseregistry.sourcegraph.com/v1/releases/sourcegraph')
65+
fetch('/api/releases')
6666
.then(res => {
6767
if (!res.ok) throw new Error('Failed to fetch releases');
6868
return res.json();

0 commit comments

Comments
 (0)