Change environment variables strategy

This commit is contained in:
Elias Schneider
2022-05-02 08:22:53 +02:00
parent 961967f57a
commit 1c90cf63ce
11 changed files with 67 additions and 26 deletions

15
src/pages/api/config.ts Normal file
View File

@@ -0,0 +1,15 @@
import type { NextApiRequest, NextApiResponse } from "next";
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
let publicEnvironmentVariables: any = {};
Object.entries(process.env).forEach(([key, value]) => {
if (key.startsWith("PUBLIC")) {
key = key.replace("PUBLIC_", "");
publicEnvironmentVariables[key] = value;
}
});
res.setHeader("cache-control", "max-age=100");
res.status(200).json(publicEnvironmentVariables);
};
export default handler;