Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion config/default-disco.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const amoCDN = 'https://addons.cdn.mozilla.net';
const staticHost = 'https://addons-discovery.cdn.mozilla.net';

module.exports = {

// The keys listed here will be exposed on the client.
// Since by definition client-side code is public these config keys
// must not contain sensitive data.
Expand Down
3 changes: 3 additions & 0 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ module.exports = {

enableClientConsole: false,

// If true node will serve the static files.
enableNodeStatics: false,

isDeployed: true,
isDevelopment: false,

Expand Down
4 changes: 3 additions & 1 deletion src/core/server/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ function baseServer(routes, createStore, { appInstanceName = appName } = {}) {
// CSP configuration.
app.use(helmet.contentSecurityPolicy(config.get('CSP')));

app.use(Express.static(path.join(config.get('basePath'), 'dist')));
if (config.get('enableNodeStatics')) {
app.use(Express.static(path.join(config.get('basePath'), 'dist')));
}

// Return version information as json
app.get('/__version__', (req, res) => {
Expand Down
33 changes: 24 additions & 9 deletions tests/server/TestConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,35 @@ import config from 'config';
const appsList = config.get('validAppNames');


describe('Config', () => {
afterEach(() => {
process.env.NODE_ENV = 'production';
delete process.env.NODE_APP_INSTANCE;
});
for (const appName of appsList) {
describe(`Config for ${appName}`, () => {
let oldNodeEnv;

before(() => {
oldNodeEnv = process.env.NODE_APP_INSTANCE;
});

beforeEach(() => {
process.env.NODE_APP_INSTANCE = appName;
process.env.NODE_ENV = 'production';
});

afterEach(() => {
process.env.NODE_ENV = oldNodeEnv;
delete process.env.NODE_APP_INSTANCE;
});

it(`should not ever have enableNodeStatics set to true for ${appName}`, () => {
const conf = requireUncached('config');
assert.equal(conf.get('enableNodeStatics'), false);
});

for (const appName of appsList) {
it(`should not ever have disableSSR set to true for ${appName}`, () => {
const conf = requireUncached('config');
assert.equal(conf.get('disableSSR'), false);
});

it(`should provide a production conf by default for ${appName}`, () => {
process.env.NODE_ENV = 'production';
const conf = requireUncached('config');
const clientConfig = getClientConfig(conf);
assert.equal(conf.get('apiHost'), 'https://addons.mozilla.org');
Expand Down Expand Up @@ -53,8 +68,8 @@ describe('Config', () => {
assert.equal(clientConfig.apiHost, 'https://addons-dev.allizom.org');
assert.equal(conf.util.getEnv('NODE_ENV'), 'development');
});
}
});
});
}


describe('Config Environment Variables', () => {
Expand Down