@@ -52,10 +52,21 @@ const systemApi = cadtApi.injectEndpoints({
5252 method : 'GET' ,
5353 } ) ,
5454 transformResponse ( baseQueryReturnValue : BaseQueryResult < Config > ) : Config | undefined {
55+ // Check if response is empty, null, or HTML content (which would indicate a 404 served as index.html)
5556 if ( _ . isEmpty ( baseQueryReturnValue ) || _ . isNil ( baseQueryReturnValue ) ) {
5657 return undefined ;
5758 }
58- return baseQueryReturnValue ;
59+
60+ if ( typeof baseQueryReturnValue === 'string' && baseQueryReturnValue . includes ( '<!doctype html>' ) ) {
61+ return undefined ;
62+ }
63+
64+ // Ensure it's a valid config object with expected structure
65+ if ( typeof baseQueryReturnValue === 'object' && baseQueryReturnValue !== null ) {
66+ return baseQueryReturnValue as Config ;
67+ }
68+
69+ return undefined ;
5970 } ,
6071 } ) ,
6172 getThemeColors : builder . query < any , void > ( {
@@ -64,10 +75,19 @@ const systemApi = cadtApi.injectEndpoints({
6475 method : 'GET' ,
6576 } ) ,
6677 transformResponse ( baseQueryReturnValue : BaseQueryResult < any > ) : any {
67- if ( _ . isEmpty ( baseQueryReturnValue ) || _ . isNil ( baseQueryReturnValue ) ) {
78+ // Check if response is empty, null, or HTML content (which would indicate a 404 served as index.html)
79+ if (
80+ _ . isEmpty ( baseQueryReturnValue ) ||
81+ _ . isNil ( baseQueryReturnValue ) ||
82+ ( typeof baseQueryReturnValue === 'string' && baseQueryReturnValue . includes ( '<!doctype html>' ) )
83+ ) {
6884 return undefined ;
6985 }
70- return baseQueryReturnValue ;
86+ // Ensure it's a valid object
87+ if ( typeof baseQueryReturnValue === 'object' && baseQueryReturnValue !== null ) {
88+ return baseQueryReturnValue ;
89+ }
90+ return undefined ;
7191 } ,
7292 } ) ,
7393 } ) ,
0 commit comments