💽 fix: Exclude index page / from static cache settings (#7382)

* Disable default static caching for app's index page

* Update index.html related environment variables in `.env.example`

* Fix linting

* Update index.spec.js

---------

Co-authored-by: Danny Avila <danacordially@gmail.com>
This commit is contained in:
Sebastien Bruel 2025-05-16 23:18:52 +09:00 committed by GitHub
parent a92ac23c44
commit 353adceb0c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 96 additions and 6 deletions

View file

@ -24,10 +24,13 @@ const routes = require('./routes');
const { PORT, HOST, ALLOW_SOCIAL_LOGIN, DISABLE_COMPRESSION, TRUST_PROXY } = process.env ?? {};
const port = Number(PORT) || 3080;
// Allow PORT=0 to be used for automatic free port assignment
const port = isNaN(Number(PORT)) ? 3080 : Number(PORT);
const host = HOST || 'localhost';
const trusted_proxy = Number(TRUST_PROXY) || 1; /* trust first proxy by default */
const app = express();
const startServer = async () => {
if (typeof Bun !== 'undefined') {
axios.defaults.headers.common['Accept-Encoding'] = 'gzip';
@ -36,7 +39,6 @@ const startServer = async () => {
logger.info('Connected to MongoDB');
await indexSync();
const app = express();
app.disable('x-powered-by');
app.set('trust proxy', trusted_proxy);
@ -179,3 +181,6 @@ process.on('uncaughtException', (err) => {
process.exit(1);
});
// export app for easier testing purposes
module.exports = app;