diff --git a/api/wakatime.js b/api/wakatime.js index 73ef9986feeb7..236727fc4e5dc 100644 --- a/api/wakatime.js +++ b/api/wakatime.js @@ -90,20 +90,11 @@ export default async (req, res) => { }), ); } catch (err) { - res.setHeader( - "Cache-Control", - `max-age=${CONSTANTS.ERROR_CACHE_SECONDS / 2}, s-maxage=${ - CONSTANTS.ERROR_CACHE_SECONDS - }, stale-while-revalidate=${CONSTANTS.ONE_DAY}`, - ); // Use lower cache period for errors. - return res.send( - renderError(err.message, err.secondaryMessage, { - title_color, - text_color, - bg_color, - border_color, - theme, - }), + setCacheControlHeaders(res, CONSTANTS.ERROR_CACHE_SECONDS); + return renderResponse( + res, + renderError(err.message, err.secondaryMessage, options), + 500 ); } };