Skip to content

Commit

Permalink
Add nocache to client runtime environment
Browse files Browse the repository at this point in the history
  • Loading branch information
fabian-emilius committed Aug 28, 2024
1 parent 548694a commit cbfd6dc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions client/public/generate-runtime-env.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { promises: fsp } = require('fs');
const { promises: fsp } = require('fs')

const ALLOWED_ENVIRONMENT_VARIABLES = [
'SERVER_HOST',
Expand All @@ -13,18 +13,22 @@ const ALLOWED_ENVIRONMENT_VARIABLES = [
'STUDY_DEGREES',
'STUDY_PROGRAMS',
'PRIVACY_NOTICE',
];
]

async function generateConfig() {
const runtimeEnvironment = {};
const runtimeEnvironment = {}

for (const key of ALLOWED_ENVIRONMENT_VARIABLES) {
if (process.env[key]) {
runtimeEnvironment[key] = process.env[key];
runtimeEnvironment[key] = process.env[key]
}
}

await fsp.writeFile('runtime-env.js', `window.RUNTIME_ENVIRONMENT_VARIABLES=${JSON.stringify(runtimeEnvironment)};\n`, 'utf-8');
await fsp.writeFile(
'runtime-env.js',
`window.RUNTIME_ENVIRONMENT_VARIABLES=${JSON.stringify(runtimeEnvironment)};\n`,
'utf-8',
)
}

void generateConfig();
void generateConfig()
2 changes: 1 addition & 1 deletion client/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ThesisTrack</title>
<script src="/runtime-env.js"></script>
<script src="/runtime-env.js?nocache=<%= new Date().getTime() %>"></script>
</head>
<body>
<div id="root"></div>
Expand Down

0 comments on commit cbfd6dc

Please sign in to comment.