Skip to content

fix: Remove unreliable IsBackOfficeRequest check from IsBlockPreviewRequest#241

Merged
rickbutterfield merged 1 commit intov5/devfrom
v5/bugfix/is-blockpreview-extension
Feb 12, 2026
Merged

fix: Remove unreliable IsBackOfficeRequest check from IsBlockPreviewRequest#241
rickbutterfield merged 1 commit intov5/devfrom
v5/bugfix/is-blockpreview-extension

Conversation

@rickbutterfield
Copy link
Copy Markdown
Owner

Summary

  • Removes the IsBackOfficeRequest() check from IsBlockPreviewRequest() which was causing false positives on frontend pages with URLs starting with /umbraco (e.g. /umbraco-explained)
  • The isBlockPreviewController check alone is sufficient — it verifies the exact controller and action match
  • Root cause: Umbraco's IsBackOfficeRequest() heuristic doesn't recognise custom backoffice API routes like /umbraco/block-preview/api/..., which led to a previous &&|| workaround (5b4fc53) that introduced the bug

Fixes #239

Test plan

  • Create a page with a URL starting with /umbraco (e.g. /umbraco-explained)
  • Add block grid/list content using IsBlockPreviewRequest() to conditionally render
  • Verify the frontend shows frontend rendering, not backend preview rendering
  • Verify the backoffice still shows block previews correctly

🤖 Generated with Claude Code

…equest

The IsBackOfficeRequest() check was returning false for BlockPreview API
routes (/umbraco/block-preview/api/...) because Umbraco's heuristic
doesn't recognise custom backoffice routes. This led to a previous
workaround (5b4fc53) changing && to ||, which caused pages with URLs
starting with /umbraco (e.g. /umbraco-explained) to incorrectly return
true on the frontend.

The isBlockPreviewController check alone is sufficient — it verifies the
exact controller and action.

Fixes #239

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 11, 2026 13:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes false positives in IsBlockPreviewRequest() on frontend pages whose URLs start with /umbraco by removing reliance on Umbraco’s heuristic IsBackOfficeRequest() check and using exact controller/action matching instead.

Changes:

  • Removed the IsBackOfficeRequest() dependency and its Umbraco.Extensions using.
  • Updated IsBlockPreviewRequest() to return true only when the request targets BlockPreviewApiController preview actions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@rickbutterfield rickbutterfield merged commit 444fd0f into v5/dev Feb 12, 2026
10 checks passed
@rickbutterfield rickbutterfield deleted the v5/bugfix/is-blockpreview-extension branch February 12, 2026 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants