Commit a5b2f0bf authored by tom's avatar tom

Add endpoint what will return the list of app ENVs

Fixes #1964
parent 3061166c
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,
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment