Skip to content

Commit 735b2be

Browse files
authored
Add rewrite rules for /developers/templates path (#931)
* Add rewrite rules for /templates path * Fix templates rewrite to strip path prefix * Skip i18n middleware for /templates path * Add basePath to templates app for proper asset loading * Make basePath conditional with env variable * Use assetPrefix instead of basePath for proxy support * Add conditional basePath for templates proxy integration * Change templates path from /templates to /developers/templates
1 parent 5a3a2cc commit 735b2be

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

apps/templates/next.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ import type { NextConfig } from "next";
44
const nextConfig: NextConfig = {
55
reactStrictMode: true,
66
trailingSlash: false,
7+
// Use basePath only when env var is set (for proxy integration)
8+
// Without env var, templates serves at root for standalone subdomain
9+
...(process.env.NEXT_PUBLIC_USE_BASE_PATH === "true" && {
10+
basePath: "/developers/templates",
11+
}),
712

813
webpack(config) {
914
// Handle inline SVGs

apps/web/rewrites-redirects.mjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@ export default {
1313
"https://solana-com-breakpoint.vercel.app/breakpoint/:path*",
1414
locale: false,
1515
},
16+
{
17+
source: "/developers/templates",
18+
destination:
19+
"https://solana-com-templates.vercel.app/developers/templates",
20+
locale: false,
21+
},
22+
// everything underneath
23+
{
24+
source: "/developers/templates/:path*",
25+
destination:
26+
"https://solana-com-templates.vercel.app/developers/templates/:path*",
27+
locale: false,
28+
},
1629
],
1730
afterFiles: [],
1831
fallback: [],

apps/web/src/middleware.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ import { locales } from "@workspace/i18n/config";
66
const handleI18nRouting = createMiddleware(routing);
77

88
export default async function middleware(req: NextRequest) {
9-
// Skip i18n for /breakpoint/* paths
10-
if (req.nextUrl.pathname.startsWith("/breakpoint")) {
9+
// Skip i18n for /breakpoint/* and /developers/templates/* paths
10+
if (
11+
req.nextUrl.pathname.startsWith("/breakpoint") ||
12+
req.nextUrl.pathname.startsWith("/developers/templates")
13+
) {
1114
return NextResponse.next();
1215
}
1316

0 commit comments

Comments
 (0)