Prefix environment variables

Hi, I was thinking about setting a prefix for the environment variables used by Manifest. Is there such a feature available now? If not, I think I can work on it, but the question is whether it would be accepted and needed? I was thinking about using this feature in applications that keep all the code within a single structure and setting a variable like PORT could affect its functionality. After the change, we would have two variables - PORT for the application server and e.g. MANIFEST_PORT for Manifest.
3 Replies
brunobuddy
brunobuddy2w ago
@fedehusk good idea. Just for information, how are you using your other application server in addition to Manifest? What would be the role of both servers ?
fedehusk
fedehuskOP2w ago
I thought about a model where the application (running e.g. Express.js) and the Manifest are stored in a single file structure. Then, in a single .env file, you could put variables for both Express and Manifest
brunobuddy
brunobuddy7d ago
yes I understand. I think it would be easier to change the port of your Express app (as EXPRESS_PORT for example) as you have more access to the code. Take this example:
// Load environment variables from .env file
require('dotenv').config();

const express = require('express');
const app = express();
const port = process.env.EXPRESS_PORT || 3000;

app.get('/', (req, res) => {
res.send('Hello World!');
});

app.listen(port, () => {
console.log(`Example app listening on port ${port}`);
});
// Load environment variables from .env file
require('dotenv').config();

const express = require('express');
const app = express();
const port = process.env.EXPRESS_PORT || 3000;

app.get('/', (req, res) => {
res.send('Hello World!');
});

app.listen(port, () => {
console.log(`Example app listening on port ${port}`);
});

Did you find this page helpful?