Some default application config is already for you defined and can be overridden in your config/default.json
or config/config.json
:
const dev = process.env.NODE_ENV !== 'production';
const baseConfig = {
application: {
env: dev ? ' (local)' : '',
basePath: '/',
host: '0.0.0.0',
port: 3000,
version: '_DPDK_VERSION_',
gtm: '',
dpdkHeaders: true,
assetUrl: '',
graphql: {
endpoint: "/api"
},
dev
}
};
There are multiple config files available for you to use. These are merged in the following order and have a particular role:
baseConfig.js <-- Default config provided by the Bootstrap.
default.json <-- Lives inside a project and is checked into GIT. This config is therefore available on all environments.
config.json <-- Lives inside a project and is not checked into GIT. The config is therefore environment specific.
One part of the config is exposed to the frontend and can be requested like this:
import getConfig from 'next/config';
const { publicRuntimeConfig } = getConfig();
This can be used for feature toggles and frontend specific tokens like Google Tag Manager.
Sometimes you need to add dynamic content to the config.
An example would be to add routes to the sitemap from MongoDB.
You can always access the config from the bootstrap an add/update config parts.
const NextBootstrap = require('@dpdk/bootstrap');
const bootstrap = new NextBootstrap(__dirname, process.cwd(), nextConfig);
bootstrap.config.dynamicParam = "Hi!";
bootstrap.init();
Last modified | Friday, April 30, 2021, 12:00:21 PM UTC |
Last author | Colin van Eenige |
Commit ID | 4c7a701 |