Skip to content

Commit

Permalink
feat: set cache control headers
Browse files Browse the repository at this point in the history
for #549
  • Loading branch information
MauriceNino committed Jan 26, 2023
1 parent 7cb2ffc commit ac12981
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions apps/api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,16 @@ app.use(compression());

if (environment.production) {
// Serve static files from the React app
app.use(express.static(path.join(__dirname, '../view')));
app.get('/', (_, res) => {
res.sendFile(path.join(__dirname, '../view', 'index.html'));
});
app.use(
express.static(path.join(__dirname, '../view'), {
maxAge: '1y',
setHeaders: (res, path) => {
if (express.static.mime.lookup(path) === 'text/html') {
res.setHeader('Cache-Control', 'public, max-age=0');
}
},
})
);
}

// Allow integrations
Expand Down

0 comments on commit ac12981

Please sign in to comment.