Skip to content

Commit

Permalink
fix review
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriellsh committed Oct 6, 2023
1 parent 1009228 commit e22806a
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions apps/meteor/app/cors/server/cors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ declare module 'meteor/webapp' {
}

// These routes already handle cache control on their own
const cacheControlledRoutes: Array<string> = ['/assets', '/custom-sounds', '/emoji-custom', '/avatar', '/file-upload'];
const cacheControlledRoutes: Array<RegExp> = ['/assets', '/custom-sounds', '/emoji-custom', '/avatar', '/file-upload'].map(
(route) => new RegExp(`^${route}`, 'i'),
);

// @ts-expect-error - accessing internal property of webapp
WebAppInternals.staticFilesMiddleware = function (
Expand All @@ -101,12 +103,7 @@ WebAppInternals.staticFilesMiddleware = function (
res.setHeader('Access-Control-Allow-Origin', '*');
const { arch, path, url } = WebApp.categorizeRequest(req);

if (
Meteor.isProduction &&
!cacheControlledRoutes.some((route) => {
return new RegExp(`^${route}`, 'gi').test(path);
})
) {
if (Meteor.isProduction && !cacheControlledRoutes.some((regexp) => regexp.test(path))) {
res.setHeader('Cache-Control', 'public, max-age=31536000');
}

Expand Down

0 comments on commit e22806a

Please sign in to comment.