@@ -35,6 +35,13 @@ Astro.response.headers.set('CDN-Cache-Control', 'public, max-age=60, stale-while
3535
3636const { locale, slug } = Astro .params ;
3737
38+ if (Astro .url .pathname .endsWith (' .json/' )) {
39+ return new Response (null , {
40+ status: 404 ,
41+ statusText: ' Not Found' ,
42+ });
43+ }
44+
3845// Validate locale
3946if (! locale || ! LOCALES .includes (locale as Locale ) || locale === DEFAULT_LOCALE ) {
4047 return Astro .redirect (' /workflows/' );
@@ -60,8 +67,15 @@ if (detailShareId) {
6067 const is404 = err instanceof Error && err .message .includes (' 404' );
6168 if (! is404 ) {
6269 console .error (' Hub API error on ISR detail:' , err );
70+ return new Response (null , {
71+ status: 502 ,
72+ statusText: ' Bad Gateway' ,
73+ });
6374 }
64- return Astro .redirect (` /${locale }/workflows/ ` );
75+ return new Response (null , {
76+ status: 404 ,
77+ statusText: ' Not Found' ,
78+ });
6579 }
6680}
6781
@@ -116,21 +130,31 @@ try {
116130// Fetch workflows for this creator from index
117131const profiles = await getProfileCache ();
118132let serialized: SerializedTemplate [] = [];
133+ let indexFetchFailed = false ;
119134
120135try {
121136 const entries = await listWorkflowIndex ();
122137 const filtered = entries .filter ((e ) => (e .profile ?.username || e .username ) === slug );
123138 serialized = filtered .map ((e ) => serializeIndexEntry (e , profiles ));
124139} catch (err ) {
140+ indexFetchFailed = true ;
125141 console .error (' Hub API failed for creator grid:' , err );
126- // Index API failed — show empty grid
127142}
128143
129144// Slug is bogus (e.g. "undefined" or a malformed "<name>-" suffix from a broken
130145// link): no profile and no workflows — redirect instead of rendering a page
131146// that would title itself "<slug> (@<slug>)" and get indexed by Google.
132147if (! isDetailPage && ! profileFound && serialized .length === 0 ) {
133- return Astro .redirect (` /${locale }/workflows/ ` );
148+ if (indexFetchFailed ) {
149+ return new Response (null , {
150+ status: 502 ,
151+ statusText: ' Bad Gateway' ,
152+ });
153+ }
154+ return new Response (null , {
155+ status: 404 ,
156+ statusText: ' Not Found' ,
157+ });
134158}
135159
136160const canonicalUrl = absoluteUrl (` /workflows/${slug }/ ` );
0 commit comments