- 
                Notifications
    You must be signed in to change notification settings 
- Fork 2.8k
Preview: Fixes a potential issue where the preview URL could be a different backoffice host #20591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…rrect backoffice host that the user initiated the preview session from originally
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request fixes preview URL generation to work correctly when Umbraco runs with a custom backoffice path. The backend now generates cleaner preview URLs without the /umbraco path segment, while the frontend dynamically prepends the correct backoffice path when needed.
Key changes:
- Backend preview URLs no longer hardcode the /umbracopath segment
- Frontend dynamically prepends the backoffice path to preview URLs when necessary
- URL info creation logic now correctly uses the IsExternalproperty
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description | 
|---|---|
| src/Umbraco.Core/Routing/NewDefaultUrlProvider.cs | Removes hardcoded /umbracopath segment from preview URL generation | 
| src/Umbraco.Cms.Api.Management/Factories/DocumentUrlFactory.cs | Fixes logic for determining when to ensure absolute URLs by using IsExternaldirectly instead of inverting it | 
| src/Umbraco.Web.UI.Client/src/packages/documents/documents/workspace/document-workspace.context.ts | Adds dynamic backoffice path handling to prepend correct path to preview URLs when needed | 
        
          
                ...braco.Web.UI.Client/src/packages/documents/documents/workspace/document-workspace.context.ts
              
                Outdated
          
            Show resolved
            Hide resolved
        
      …e the parameter altogether
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
        
          
                ...braco.Web.UI.Client/src/packages/documents/documents/workspace/document-workspace.context.ts
              
                Outdated
          
            Show resolved
            Hide resolved
        
      | Test DirectionsTest 1: Production Build Preview (Regression Test)First, verify the fix doesn't break the standard production scenario. 
 Test 2: Vite Dev Server Preview (Main Bug Fix)Now test the primary use case - developing with the Vite dev server. 
 What ChangedBefore this fix: 
 After this fix: 
 | 
        
          
                ...braco.Web.UI.Client/src/packages/documents/documents/workspace/document-workspace.context.ts
              
                Outdated
          
            Show resolved
            Hide resolved
        
      …eview-external-urls
… `<base>` tag is taken into consideration - that way the URL will open on whatever host is active
This pull request fixes preview URL generation when the backoffice is accessed from a different path than the default
/umbraco. This particularly affects development workflows using the Vite dev server.Problem
When developing with the Vite dev server (typically running on
https://localhost:5173/), clicking Preview would generate URLs like/umbraco/preview?id=.... Since the Vite dev server doesn't have the/umbracoprefix, these URLs would fail to load.Example Scenario:
https://localhost:5173/(backoffice client)https://localhost:44339/umbraco(API endpoints)https://localhost:5173/umbraco/preview?id=...❌https://localhost:5173/preview?id=...✅Solution
Backend Changes:
/umbracopath from preview URL generation inNewDefaultUrlProvider.csDocumentUrlFactory.csto return raw URLs without absolute URL conversionpreview?id=...so they use the<base>tag in the browser automaticallyFrontend Changes:
Benefits