Skip to content

Commit

Permalink
add middleware changes
Browse files Browse the repository at this point in the history
  • Loading branch information
helios2003 committed Jul 9, 2024
1 parent 6ec2186 commit 9703ac0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
3 changes: 1 addition & 2 deletions apps/studio-next/src/app/api/crawler/route.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { NextRequest, NextResponse } from "next/server";
import parseURL from "@/helpers/parser";
import { DocumentInfo } from "@/types";
import fetch from "node-fetch";

export async function GET(request: NextRequest) {
try {
const searchParams = request.nextUrl.searchParams.get('base64');
if (!searchParams) return new NextResponse(null, { status: 200 });
const info: DocumentInfo = await parseURL(searchParams);

const ogImageurl = `https://ogp-studio.vercel.app/api/og?title=${encodeURIComponent(info.title!)}&description=${encodeURIComponent(info.description!)}&numServers=${info.numServers}&numChannels=${info.numChannels}`;
const ogImageurl = `https://ogp-studio.netlify.app/api/og?title=${encodeURIComponent(info.title!)}&description=${encodeURIComponent(info.description!)}&numServers=${info.numServers}&numChannels=${info.numChannels}`;

const crawlerInfo = `
<!DOCTYPE html>
Expand Down
21 changes: 21 additions & 0 deletions apps/studio-next/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
import dynamic from 'next/dynamic';
const StudioWrapper = dynamic(() => import('@/components/StudioWrapper'), {ssr: false})
import { Metadata } from 'next';
import ogImage from '@/img/meta-studio-og-image.jpeg';

export const metadata: Metadata = {
metadataBase: new URL('https://studio-next.netlify.app'),
openGraph: {
type: 'website',
title: 'AsyncAPI Studio',
description: 'Studio for AsyncAPI specification, where you can validate, view preview documentation, and generate templates from AsyncAPI document.',
url: 'https://studio-next.netlify.app',
images: [
{
url: ogImage.src,
width: 800,
height: 600,
alt: 'AsyncAPI default image',
},
]
},
twitter: {
site: '@AsyncAPISpec',
}
}
export default async function Home() {
return (
<StudioWrapper />
Expand Down
1 change: 0 additions & 1 deletion apps/studio-next/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export async function middleware(request: NextRequest) {
if (!encodedDocument) {
return res;
}
//const redirectService = `https://studio-crawler-redirect.vercel.app/api?title=${info.title}&description=${info.description}`;
return NextResponse.rewrite(new URL(`/api/crawler?base64=${encodedDocument}`, request.url));
}
}
Expand Down

0 comments on commit 9703ac0

Please sign in to comment.