Merge pull request #1987 from blockscout/tom2drum/issue-1964

Add endpoint what will return the list of app ENVs
This commit is contained in:
tom goriunov
2024-06-05 14:43:26 +04:00
committed by GitHub
+16
View File
@@ -0,0 +1,16 @@
import type { NextApiRequest, NextApiResponse } from 'next';
export default async function configHandler(req: NextApiRequest, res: NextApiResponse) {
// eslint-disable-next-line no-restricted-properties
const publicEnvs = Object.entries(process.env)
.filter(([ key ]) => key.startsWith('NEXT_PUBLIC_'))
.sort(([ keyA ], [ keyB ]) => keyA.localeCompare(keyB))
.reduce((result, [ key, value ]) => {
result[key] = value || '';
return result;
}, {} as Record<string, string>);
res.status(200).json({
envs: publicEnvs,
});
}