Skip to content

Fix for 401/403 Errors#575

Open
SharonStrats wants to merge 2 commits intomainfrom
fix/failed-to-load-errors
Open

Fix for 401/403 Errors#575
SharonStrats wants to merge 2 commits intomainfrom
fix/failed-to-load-errors

Conversation

@SharonStrats
Copy link
Contributor

Ticket SolidOS/solidos#263

Some changes we could make to improve the flow and provide better user experience.

Copy link
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

This PR aims to reduce confusing 401/403 experiences by improving how SolidOS handles authentication-related fetch failures and by avoiding an initial fetch of / when the app is loaded at the bare root URL.

Changes:

  • Detect 401/403-like errors during outline expansion and display a login-oriented message instead of a raw error.
  • Update main page initialization so that visiting bare / (without an explicit target URI) attempts to land on the logged-in user’s WebID/profile rather than dereferencing /.
  • Add an optional “safe landing” override via localStorage.solidosSafeLandingUri for logged-in users when a WebID isn’t immediately available.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/outline/manager.js Adds auth-error detection to replace raw 401/403 errors with a clearer user-facing message during outline fetch failures.
src/mainPage/index.ts Changes startup navigation logic at the bare app root to avoid fetching / and optionally redirect logged-in users to profile/safe landing.

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

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines 2114 to 2119
const message = UI.widgets.errorMessageBlock(
dom,
detail,
'#fee',
errObj instanceof Error ? errObj : undefined
isAuthError ? 'You need to log in to see this resource.' : detail,
isAuthError ? '#d8d8d8' : '#fee',
!isAuthError && errObj instanceof Error ? errObj : undefined
)
const isLoggedIn = !!(authSession.info && authSession.info.isLoggedIn)
const isBareAppRoot = locationUrl.pathname === '/' && !locationUrl.search && !locationUrl.hash

if (isBareAppRoot && !hasExplicitUriArg && !explicitUriQuery) {
Comment on lines +40 to +42
const fallbackUrl = new URL(configuredLandingUri, locationUrl.origin)
if (!(fallbackUrl.origin === locationUrl.origin && fallbackUrl.pathname === '/')) {
outliner.GotoSubject(store.sym(fallbackUrl.toString()), true, undefined, true, undefined)
Comment on lines +2111 to +2112
const isAuthError = errorStatus === 401 || errorStatus === 403 ||
errorStatus === '401' || errorStatus === '403' ||
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