Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion frontend/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@
xfwd: true,
}),
)
app.use(
'/version/',
createProxyMiddleware({
changeOrigin: true,
target: process.env.FLAGSMITH_PROXY_API_URL,
xfwd: true,
}),
)
}

if (isDev) {
Expand Down Expand Up @@ -179,34 +187,34 @@
res.send('OK')
})

app.get('/version', (req, res) => {
app.get('/_frontend_version', (req, res) => {
let commitSha = 'Unknown'
let imageTag = 'Unknown'

try {
commitSha = fs
.readFileSync('CI_COMMIT_SHA', 'utf8')
.replace(/(\r\n|\n|\r)/gm, '')
} catch (err) {
// eslint-disable-next-line
console.log('Unable to read CI_COMMIT_SHA')
}

try {
let releasePleaseManifest = JSON.parse(
fs.readFileSync('./.versions.json', 'utf8'),
)
res.send({
'ci_commit_sha': commitSha,
'image_tag': releasePleaseManifest['.'],
'package_versions': releasePleaseManifest,
})
} catch (err) {
// eslint-disable-next-line
console.log('Unable to read .versions.json file')
res.send({ 'ci_commit_sha': commitSha, 'image_tag': imageTag })
}
})

Check failure

Code scanning / CodeQL

Missing rate limiting High

This route handler performs
a file system access
, but is not rate-limited.
This route handler performs
a file system access
, but is not rate-limited.

app.use(bodyParser.json())
app.use(spm)
Expand Down
2 changes: 1 addition & 1 deletion frontend/common/services/useBuildVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const buildVersionService = service
queryFn: async (args, _, _2, baseQuery) => {
try {
const [frontendRes, backendRes] = await Promise.all([
data.get(`/version/`).catch(() => ({})),
data.get(`/_frontend_version`).catch(() => ({})),
data.get(`${Project.api.replace('api/v1/', '')}version/`),
])

Expand Down
Loading