@@ -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,18 @@ 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+ headers: {
74+ ' CDN-Cache-Control' : ' no-store' ,
75+ },
76+ });
6377 }
64- return Astro .redirect (` /${locale }/workflows/ ` );
78+ return new Response (null , {
79+ status: 404 ,
80+ statusText: ' Not Found' ,
81+ });
6582 }
6683}
6784
@@ -116,21 +133,34 @@ try {
116133// Fetch workflows for this creator from index
117134const profiles = await getProfileCache ();
118135let serialized: SerializedTemplate [] = [];
136+ let indexFetchFailed = false ;
119137
120138try {
121139 const entries = await listWorkflowIndex ();
122140 const filtered = entries .filter ((e ) => (e .profile ?.username || e .username ) === slug );
123141 serialized = filtered .map ((e ) => serializeIndexEntry (e , profiles ));
124142} catch (err ) {
143+ indexFetchFailed = true ;
125144 console .error (' Hub API failed for creator grid:' , err );
126- // Index API failed — show empty grid
127145}
128146
129147// Slug is bogus (e.g. "undefined" or a malformed "<name>-" suffix from a broken
130148// link): no profile and no workflows — redirect instead of rendering a page
131149// that would title itself "<slug> (@<slug>)" and get indexed by Google.
132150if (! isDetailPage && ! profileFound && serialized .length === 0 ) {
133- return Astro .redirect (` /${locale }/workflows/ ` );
151+ if (indexFetchFailed ) {
152+ return new Response (null , {
153+ status: 502 ,
154+ statusText: ' Bad Gateway' ,
155+ headers: {
156+ ' CDN-Cache-Control' : ' no-store' ,
157+ },
158+ });
159+ }
160+ return new Response (null , {
161+ status: 404 ,
162+ statusText: ' Not Found' ,
163+ });
134164}
135165
136166const canonicalUrl = absoluteUrl (` /workflows/${slug }/ ` );
0 commit comments