@@ -18,7 +18,7 @@ export interface DomainHealthResult {
1818 message ?: string ;
1919}
2020
21- const normalizeUrl = ( domain : string ) : string => {
21+ const normaliseUrl = ( domain : string ) : string => {
2222 return / ^ h t t p s ? : \/ \/ / i. test ( domain ) ? domain : `https://${ domain } ` ;
2323} ;
2424
@@ -35,7 +35,7 @@ export const checkDomainHealth = async (
3535 }
3636
3737 try {
38- const response = await httpClient . get ( normalizeUrl ( domain ) , {
38+ const response = await httpClient . get ( normaliseUrl ( domain ) , {
3939 maxRedirects : 0 ,
4040 /* c8 ignore next */
4141 validateStatus : ( ) => true ,
@@ -76,14 +76,24 @@ const isHealthy = (results: DomainHealthResult[]): boolean => {
7676 return results . every ( ( result ) => result . status === 'success' ) ;
7777} ;
7878
79+ const setNoCacheHeaders = ( res : Response ) : void => {
80+ res . set ( {
81+ 'Cache-Control' : 'no-store, no-cache, must-revalidate, proxy-revalidate' ,
82+ Pragma : 'no-cache' ,
83+ Expires : '0' ,
84+ 'Surrogate-Control' : 'no-store' ,
85+ } ) ;
86+ } ;
87+
7988const healthController = {
8089 /**
8190 * Checks the configured embed domains and returns their reachability status.
8291 * @param {Request } _req - Express request object.
8392 * @param {Response } res - Express response object.
8493 * @returns {Promise<Response> } JSON response containing domain health information.
85- */
94+ */
8695 async getEmbedDomains ( req : Request , res : Response ) : Promise < Response > {
96+ setNoCacheHeaders ( res ) ;
8797 const target = typeof req . query . target === 'string' ? req . query . target . toLowerCase ( ) : undefined ;
8898
8999 // Return 400 if there is no `MULTI_DOMAIN` configured
@@ -117,7 +127,6 @@ const healthController = {
117127 }
118128
119129 const domains = await Promise . all ( checks ) ;
120-
121130 const healthy = isHealthy ( domains ) ;
122131 return res . status ( healthy ? 200 : 503 ) . json ( { domains, status : healthy ? 'success' : 'error' } ) ;
123132 } ,
@@ -129,6 +138,7 @@ const healthController = {
129138 * @returns {Promise<Response> } JSON response containing APP_URL health information.
130139 */
131140 async getAppUrl ( _req : Request , res : Response ) : Promise < Response > {
141+ setNoCacheHeaders ( res ) ;
132142 const domain = await checkDomainHealth ( 'APP_URL' , appConfig . APP_URL ) ;
133143 const healthy = domain . status === 'success' ;
134144 return res . status ( healthy ? 200 : 503 ) . json ( domain ) ;
0 commit comments