Skip to content

Commit 3bb28ff

Browse files
authored
Merge pull request #272 from shurco/271-bug-incorrect-redirect-to-install-page-on-500-errors-when-installing
🐛 fix(api): prevent incorrect redirect to install page on GitHub API …
2 parents f0fc483 + e02870c commit 3bb28ff

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

internal/handlers/private/setting.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ func Version(c *fiber.Ctx) error {
3333
if err == sql.ErrNoRows {
3434
version = update.VersionInfo()
3535

36+
// Try to fetch latest release, but don't fail if GitHub API is unavailable
3637
release, err := update.FetchLatestRelease(context.Background(), "shurco", "litecart")
3738
if err != nil {
39+
// Log the error but continue without update information
40+
// This prevents blocking access when GitHub API is unavailable
3841
log.ErrorStack(err)
39-
return webutil.StatusInternalServerError(c)
40-
}
41-
42-
if version.CurrentVersion != release.Name {
42+
} else if version.CurrentVersion != release.Name {
4343
version.NewVersion = release.Name
4444
version.ReleaseURL = release.GetUrl()
4545
}

web/admin/src/routes/+layout.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ export const load: LayoutLoad = async ({ url, fetch }) => {
3737
if (versionData?.success) {
3838
isAuthenticated = true
3939
}
40-
} else if (versionResponse.status === 500) {
41-
// Server error - likely means app is not installed
42-
// Backend should handle this, but for client-side navigation, redirect to install
43-
throw redirect(302, `${base}/install`)
4440
} else if (versionResponse.status === 400 || versionResponse.status === 401 || versionResponse.status === 403) {
4541
// 400 = missing/malformed token (app installed but not authenticated)
4642
// 401/403 = unauthorized (app installed but not authenticated)
@@ -72,9 +68,6 @@ export const load: LayoutLoad = async ({ url, fetch }) => {
7268
// 400 = missing/malformed token (app installed but not authenticated)
7369
// 401/403 = unauthorized (app installed but not authenticated)
7470
throw redirect(302, `${base}/signin`)
75-
} else if (productsResponse.status === 500) {
76-
// Server error - likely means app is not installed
77-
throw redirect(302, `${base}/install`)
7871
}
7972
} catch (error) {
8073
// If it's already a redirect, rethrow it

0 commit comments

Comments
 (0)