Skip to content

Commit e01b5de

Browse files
authored
docs(nx-dev): invert Framer proxy to default-proxy, keep only Next.js paths (#34672)
## Current Behavior The Netlify edge function reads `NEXT_PUBLIC_FRAMER_REWRITES` env var to determine which paths to proxy to Framer. As more pages move to Framer, this growing allowlist becomes cumbersome to maintain. ## Expected Behavior The edge function now proxies all requests to Framer by default. Only paths explicitly listed in `nextjsPaths` and `excludedPath` are served by Next.js. This removes the need for the `NEXT_PUBLIC_FRAMER_REWRITES` env var (should be removed from Netlify dashboard manually). Deleted 25 page files (pages router + app router) that are now served by Framer: homepage, 404, enterprise/*, contact/*, solutions/*, community, company, customers, nx-cloud, partners, brands, careers, java, react, remote-cache, resources, webinar. **Next.js paths kept:** `/blog/*`, `/courses/*`, `/pricing`, `/podcast`, `/ai-chat`, `/changelog`, `/resources-library`, `/whitepaper-fast-ci`, `/500`, `/api/*`, `/docs/*` **Manual follow-up:** Remove `NEXT_PUBLIC_FRAMER_REWRITES` env var from Netlify dashboard. ## Related Issue(s) Closes DOC-431
1 parent f42be4e commit e01b5de

367 files changed

Lines changed: 201 additions & 34506 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

netlify/edge-functions/README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ We attempted to configure a custom path via `edge_functions = "nx-dev/nx-dev/net
1717

1818
### `rewrite-framer-urls.ts`
1919

20-
Proxies requests to Framer-hosted pages and rewrites URLs in the HTML response to use `nx.dev` instead of the Framer domain. This ensures:
20+
Proxies all requests to Framer by default and rewrites URLs in the HTML response to use `nx.dev` instead of the Framer domain. Only paths explicitly kept in Next.js (defined in the `nextjsPaths` set and `excludedPath` config) bypass the proxy.
21+
22+
This ensures:
2123

2224
- Canonical URLs point to nx.dev
2325
- No duplicate indexing by search engines
@@ -26,7 +28,16 @@ Proxies requests to Framer-hosted pages and rewrites URLs in the HTML response t
2628
**Environment variables** (configured in Netlify):
2729

2830
- `NEXT_PUBLIC_FRAMER_URL`: The Framer site URL (e.g., `https://ready-knowledge-238309.framer.app`)
29-
- `NEXT_PUBLIC_FRAMER_REWRITES`: Comma-separated list of paths to proxy (e.g., `/enterprise,/powerpack`)
31+
32+
### `framer-sitemap.ts`
33+
34+
Proxies Framer's `sitemap.xml` at the path `/sitemap-1.xml` and rewrites URLs to use `nx.dev`. This is a separate edge function from the main Framer proxy so that the main function can keep `accept: ['text/html']` for compute cost savings.
35+
36+
The Next.js sitemap index (`sitemap.xml`) references `/sitemap-1.xml` via the `additionalSitemaps` config in `next-sitemap.config.js`.
37+
38+
**Environment variables** (configured in Netlify):
39+
40+
- `NEXT_PUBLIC_FRAMER_URL`: Same as the main proxy function
3041

3142
## Future
3243

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import type { Context } from 'https://edge.netlify.com';
2+
3+
const framerUrl = Netlify.env.get('NEXT_PUBLIC_FRAMER_URL');
4+
5+
/**
6+
* Proxies Framer's sitemap.xml and rewrites URLs to nx.dev.
7+
*
8+
* This is a separate edge function from the main Framer proxy so that
9+
* the main function can keep `accept: ['text/html']` for cost savings.
10+
*/
11+
export default async function handler(
12+
request: Request,
13+
context: Context
14+
): Promise<Response> {
15+
if (!framerUrl) return context.next();
16+
17+
const response = await fetch(new URL('/sitemap.xml', framerUrl).toString(), {
18+
headers: {
19+
'User-Agent': request.headers.get('User-Agent') || '',
20+
Accept: request.headers.get('Accept') || 'application/xml',
21+
},
22+
});
23+
24+
if (!response.ok) {
25+
return new Response('Sitemap not available', { status: 502 });
26+
}
27+
28+
const xml = await response.text();
29+
const rewrittenXml = xml.replaceAll(framerUrl, 'https://nx.dev');
30+
31+
const newHeaders = new Headers(response.headers);
32+
newHeaders.set('content-type', 'application/xml; charset=utf-8');
33+
newHeaders.set('x-nx-edge-function', 'framer-sitemap');
34+
newHeaders.set('Cache-Control', 'public, max-age=3600, must-revalidate');
35+
36+
return new Response(rewrittenXml, {
37+
status: 200,
38+
headers: newHeaders,
39+
});
40+
}
41+
42+
export const config = {
43+
path: ['/sitemap-1.xml'],
44+
};

netlify/edge-functions/rewrite-framer-urls.ts

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
import type { Context } from 'https://edge.netlify.com';
22

33
const framerUrl = Netlify.env.get('NEXT_PUBLIC_FRAMER_URL');
4-
const framerPaths = new Set(
5-
(Netlify.env.get('NEXT_PUBLIC_FRAMER_REWRITES') || '')
6-
.split(',')
7-
.map((p) => p.trim())
8-
.filter((p) => p.length > 0)
9-
.map((p) => (p.startsWith('/') ? p : `/${p}`))
10-
);
4+
5+
/**
6+
* Paths that should be served by the Next.js app instead of Framer.
7+
* Everything else is proxied to Framer.
8+
*/
9+
const nextjsPaths = new Set([
10+
'/blog',
11+
'/courses',
12+
'/pricing',
13+
'/podcast',
14+
'/ai-chat',
15+
'/changelog',
16+
'/resources-library',
17+
'/whitepaper-fast-ci',
18+
'/500',
19+
]);
1120

1221
/**
1322
* Proxies requests to Framer and rewrites URLs in responses.
1423
*
15-
* This edge function:
16-
* 1. Checks if the request path matches a Framer-proxied path
17-
* 2. If yes, fetches directly from Framer
18-
* 3. Rewrites Framer URLs to nx.dev in the response
19-
* 4. If not a Framer path, passes through to Next.js
24+
* This edge function proxies all requests to Framer by default.
25+
* Only paths explicitly listed in `nextjsPaths` (and those in
26+
* the `excludedPath` config) are passed through to Next.js.
2027
*
2128
* This ensures canonical URLs and other references point to nx.dev
2229
* instead of the Framer domain, avoiding duplicate indexing issues.
@@ -28,7 +35,7 @@ export default async function handler(
2835
const url = new URL(request.url);
2936
const pathname = url.pathname;
3037

31-
if (!framerUrl || !framerPaths.has(pathname)) return context.next();
38+
if (!framerUrl || nextjsPaths.has(pathname)) return context.next();
3239

3340
const framerDestination = new URL(pathname, framerUrl);
3441
url.searchParams.forEach((value, key) => {
@@ -67,5 +74,24 @@ export const config = {
6774
path: ['/*'],
6875
// Only process HTML requests to save on compute
6976
accept: ['text/html'],
70-
excludedPath: ['/docs/*', '/api/*', '/_next/*', '/favicon.ico'],
77+
excludedPath: [
78+
'/docs/*',
79+
'/api/*',
80+
'/blog/*',
81+
'/courses/*',
82+
'/_next/*',
83+
'/favicon.ico',
84+
'/webinar',
85+
'/sitemap.xml',
86+
'/sitemap-*.xml',
87+
// Static asset directories from public/ — must not be proxied to Framer
88+
'/documentation/*',
89+
'/assets/*',
90+
'/images/*',
91+
'/fonts/*',
92+
'/videos/*',
93+
'/data/*',
94+
'/socials/*',
95+
'/favicon/*',
96+
],
7197
};

nx-dev/data-access-careers/.babelrc

Lines changed: 0 additions & 12 deletions
This file was deleted.

nx-dev/data-access-careers/.eslintrc.json

Lines changed: 0 additions & 18 deletions
This file was deleted.

nx-dev/data-access-careers/README.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

nx-dev/data-access-careers/node-only/index.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

nx-dev/data-access-careers/package.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

nx-dev/data-access-careers/project.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

nx-dev/data-access-careers/src/lib/api.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)