Open rohanrichards opened 6 years ago
I now do this:
export const env = process.env.NODE_ENV;
export const port = process.env.PORT || 9000;
// List of user roles
export const userRoles = ['guest', 'user', 'admin'];
export default {
env,
port,
userRoles,
};
that seems to work...
When accessing constants like so
import constants from './app.constants';
The object is defined with this structure:Within
app.module.ts
an if statement appears which ads an injectable to the app (I don't understand what it does)The if statement always fails as
constants.env
is always undefined. The correct way to access the variable would be withconstants.default.env
Within
server/config/environment/shared.js
the export appears asmodule.exports.default
and I have changed this to remove the default. Now my constants object can be accessed as above (constants.env
)This works fine, however I now have a CORS error when I run my app:
CORS header ‘Access-Control-Allow-Origin’ missing
I believe this is due to the Injectable code withinapp.module.ts
(commenting out the code resolves the issue).Finally, while testing shared.js I have noticed that it does not correctly import any process.env variables, and it seems the gulpfile is missing the task to copy them across. What is the appropriate way currently to get environment variables to the client side?