Skip to content

feat(nx-dev): add conditional blog/changelog proxy in edge function#35043

Merged
jaysoo merged 2 commits into
masterfrom
DOC-455
Mar 27, 2026
Merged

feat(nx-dev): add conditional blog/changelog proxy in edge function#35043
jaysoo merged 2 commits into
masterfrom
DOC-455

Conversation

@jaysoo

@jaysoo jaysoo commented Mar 27, 2026

Copy link
Copy Markdown
Member

Current Behavior

/blog and /changelog paths are always served by the Next.js app. The Netlify edge function excludes these paths (/blog/* in excludedPath, /blog and /changelog in nextjsPaths) so they bypass the Framer proxy and fall through to Next.js.

Expected Behavior

When the BLOG_URL env var is set in Netlify, /blog/* and /changelog/* requests are proxied to the standalone blog site (e.g., nrwl-blog.netlify.app) via the existing Netlify edge function. When BLOG_URL is not set, behavior is unchanged — paths fall through to Next.js as before.

Changes to netlify/edge-functions/rewrite-framer-urls.ts:

  • Read BLOG_URL env var
  • Conditionally remove /blog and /changelog from nextjsPaths when BLOG_URL is set
  • Remove /blog/* and /changelog from static excludedPath so the edge function can intercept these paths
  • Add blog proxy branch: when BLOG_URL is set and path matches, proxy to blog site with URL rewriting (blogUrlhttps://nx.dev) and security headers (X-Frame-Options, CSP)
  • When BLOG_URL is unset, blog/changelog paths fall through to Next.js via explicit context.next() guard

Asset resolution note: The edge function only handles text/html requests. Blog site assets (CSS, JS) will need to be served from the blog site's own CDN (via build.assetsPrefix or equivalent in the blog repo). All existing /_next/* assets remain in excludedPath and are unaffected.

Related Issue(s)

Fixes DOC-455

## Current Behavior

/blog and /changelog paths are always served by the Next.js app.

## Expected Behavior

When the `BLOG_URL` env var is set in Netlify, /blog/*, /changelog/*
are proxied to the standalone blog site (e.g. nrwl-blog.netlify.app).
When unset, behavior is unchanged — paths fall through to Next.js.

The proxy runs in the existing Netlify edge function alongside the
Framer proxy, using `beforeFiles` semantics to override local routes.
Includes URL rewriting (blogUrl → nx.dev) and security headers.

## Related Issue(s)

Fixes DOC-455
@jaysoo jaysoo requested a review from a team as a code owner March 27, 2026 16:45
@jaysoo jaysoo requested a review from FrozenPandaz March 27, 2026 16:45
@netlify

netlify Bot commented Mar 27, 2026

Copy link
Copy Markdown

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit fd2b6b7
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/69c6bfd986e6990008644608
😎 Deploy Preview https://deploy-preview-35043--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Mar 27, 2026

Copy link
Copy Markdown

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit fd2b6b7
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/69c6bfd94ff89d0008b6ab51
😎 Deploy Preview https://deploy-preview-35043--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nx-cloud

nx-cloud Bot commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit fd2b6b7

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 7m 45s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 7s View ↗
nx-cloud record -- pnpm nx conformance:check ✅ Succeeded 7s View ↗
nx build workspace-plugin ✅ Succeeded <1s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-27 17:47:08 UTC

Comment thread netlify/edge-functions/rewrite-framer-urls.ts
## Current Behavior
Browsers request /favicon.ico but the file lives at /favicon/favicon.ico,
resulting in a 404.

## Expected Behavior
/favicon.ico redirects to /favicon/favicon.ico and serves correctly.
@jaysoo jaysoo merged commit a8b5d04 into master Mar 27, 2026
24 checks passed
@jaysoo jaysoo deleted the DOC-455 branch March 27, 2026 18:04
FrozenPandaz pushed a commit that referenced this pull request Mar 31, 2026
…35043)

## Current Behavior

`/blog` and `/changelog` paths are always served by the Next.js app. The
Netlify edge function excludes these paths (`/blog/*` in `excludedPath`,
`/blog` and `/changelog` in `nextjsPaths`) so they bypass the Framer
proxy and fall through to Next.js.

## Expected Behavior

When the `BLOG_URL` env var is set in Netlify, `/blog/*` and
`/changelog/*` requests are proxied to the standalone blog site (e.g.,
`nrwl-blog.netlify.app`) via the existing Netlify edge function. When
`BLOG_URL` is **not** set, behavior is unchanged — paths fall through to
Next.js as before.

**Changes to `netlify/edge-functions/rewrite-framer-urls.ts`:**

- Read `BLOG_URL` env var
- Conditionally remove `/blog` and `/changelog` from `nextjsPaths` when
`BLOG_URL` is set
- Remove `/blog/*` and `/changelog` from static `excludedPath` so the
edge function can intercept these paths
- Add blog proxy branch: when `BLOG_URL` is set and path matches, proxy
to blog site with URL rewriting (`blogUrl` → `https://nx.dev`) and
security headers (`X-Frame-Options`, `CSP`)
- When `BLOG_URL` is unset, blog/changelog paths fall through to Next.js
via explicit `context.next()` guard

**Asset resolution note:** The edge function only handles `text/html`
requests. Blog site assets (CSS, JS) will need to be served from the
blog site's own CDN (via `build.assetsPrefix` or equivalent in the blog
repo). All existing `/_next/*` assets remain in `excludedPath` and are
unaffected.

## Related Issue(s)

Fixes DOC-455

(cherry picked from commit a8b5d04)
jaysoo added a commit that referenced this pull request Apr 1, 2026
…35043)

## Current Behavior

`/blog` and `/changelog` paths are always served by the Next.js app. The
Netlify edge function excludes these paths (`/blog/*` in `excludedPath`,
`/blog` and `/changelog` in `nextjsPaths`) so they bypass the Framer
proxy and fall through to Next.js.

## Expected Behavior

When the `BLOG_URL` env var is set in Netlify, `/blog/*` and
`/changelog/*` requests are proxied to the standalone blog site (e.g.,
`nrwl-blog.netlify.app`) via the existing Netlify edge function. When
`BLOG_URL` is **not** set, behavior is unchanged — paths fall through to
Next.js as before.

**Changes to `netlify/edge-functions/rewrite-framer-urls.ts`:**

- Read `BLOG_URL` env var
- Conditionally remove `/blog` and `/changelog` from `nextjsPaths` when
`BLOG_URL` is set
- Remove `/blog/*` and `/changelog` from static `excludedPath` so the
edge function can intercept these paths
- Add blog proxy branch: when `BLOG_URL` is set and path matches, proxy
to blog site with URL rewriting (`blogUrl` → `https://nx.dev`) and
security headers (`X-Frame-Options`, `CSP`)
- When `BLOG_URL` is unset, blog/changelog paths fall through to Next.js
via explicit `context.next()` guard

**Asset resolution note:** The edge function only handles `text/html`
requests. Blog site assets (CSS, JS) will need to be served from the
blog site's own CDN (via `build.assetsPrefix` or equivalent in the blog
repo). All existing `/_next/*` assets remain in `excludedPath` and are
unaffected.

## Related Issue(s)

Fixes DOC-455
@github-actions

github-actions Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 2, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants