diff --git a/apps/arkmarket/src/app/[collectionAddress]/[tokenId]/page.tsx b/apps/arkmarket/src/app/[collectionAddress]/[tokenId]/page.tsx new file mode 100644 index 00000000..5fd6bc4b --- /dev/null +++ b/apps/arkmarket/src/app/[collectionAddress]/[tokenId]/page.tsx @@ -0,0 +1,12 @@ +import { notFound } from "next/navigation"; +import { ChainId, CollectionAddresses } from "~/config/homepage"; +import TokenPage from "~/app/token/[contractAddress]/[tokenId]/page"; + +export default function TokenPageRoute({ params }) { + const collection = CollectionAddresses[params.collectionAddress]; + if (undefined === collection) { + return notFound() + } + const address = collection[ChainId.SN_MAIN]; + return TokenPage({ params: { contractAddress: address, tokenId: params.tokenId } }) +} diff --git a/apps/arkmarket/src/middleware.ts b/apps/arkmarket/src/middleware.ts deleted file mode 100644 index dc1aa5d8..00000000 --- a/apps/arkmarket/src/middleware.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { NextResponse } from 'next/server' -import type { NextRequest } from 'next/server' -import type { Collections } from './config/homepage'; -import { ChainId, CollectionAddresses } from './config/homepage'; - -// This function can be marked `async` if using `await` inside -export function middleware(request: NextRequest) { - // index 0 is the first / at index 1 we got collection name - const splittedPath = request.nextUrl.pathname.split('/') - const collectionName = splittedPath[1] as Collections; - const collectionAddress = CollectionAddresses[collectionName]; - if (undefined === collectionAddress) { - return NextResponse.next() - } - const address = collectionAddress[ChainId.SN_MAIN]; - - return NextResponse.rewrite(request.nextUrl.origin + '/token/' + address + '/' + splittedPath[2]) -} - -export const config = { - matcher: [ - /* - * Match all request paths except for the ones starting with: - * - api (API routes) - * - _next/static (static files) - * - _next/image (image optimization files) - * - favicon.ico, sitemap.xml, robots.txt (metadata files) - */ - '/((?!api|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)', - ], -}