Skip to content

Commit 0495cc5

Browse files
committed
fix: ssr render 404 page for orgs
1 parent 4074e9b commit 0495cc5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

app/composables/npm/useOrgPackages.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export function useOrgPackages(orgName: MaybeRefOrGetter<string>) {
8989

9090
const asyncData = useLazyAsyncData(
9191
() => `org-packages:${searchProvider.value}:${toValue(orgName)}`,
92-
async ({ $npmRegistry, $npmApi }, { signal }) => {
92+
async ({ $npmRegistry, $npmApi, ssrContext }, { signal }) => {
9393
const org = toValue(orgName)
9494
if (!org) {
9595
return emptySearchResponse
@@ -120,11 +120,15 @@ export function useOrgPackages(orgName: MaybeRefOrGetter<string>) {
120120
} catch (err) {
121121
// Check if this is a 404 (org not found)
122122
if (err && typeof err === 'object' && 'statusCode' in err && err.statusCode === 404) {
123-
throw createError({
123+
const error = createError({
124124
statusCode: 404,
125125
statusMessage: 'Organization not found',
126126
message: `The organization "@${org}" does not exist on npm`,
127127
})
128+
if (import.meta.server) {
129+
ssrContext!.payload.error = error
130+
}
131+
throw error
128132
}
129133
// For other errors (network, etc.), return empty array to be safe
130134
packageNames = []

0 commit comments

Comments
 (0)