A Custom Application configuration file defines the necessary requirements to develop and build your application.
custom-application-config.json in the root of your project directory (next to package.json).Supported file extensions
custom-application-config..json, .js, .cjs, .mjs, .ts.For example:
import { entryPointUriPath } from './constants';
const name = 'Test application';
/**
* @type {import('@commercetools-frontend/application-config').ConfigOptions}
*/
const config = {
name,
entryPointUriPath,
// ...
};
module.exports = config;
const entryPointUriPath = 'test';
module.exports = { entryPointUriPath };
Editor support
To facilitate the usage of the application config, you should instruct your editor to provide hints and code completion (IntelliSense) depending on the format of the configuration file.
Use JSDoc @type expression
@type tag, pointing it to the exported TypeScript declaration of the @commercetools-frontend/application-config package./**
* @type {import('@commercetools-frontend/application-config').ConfigOptions}
*/
const config = {
// ...
};
module.exports = config;
.ts, you can import the type directly instead.import type { ConfigOptions } from '@commercetools-frontend/application-config';
const config: ConfigOptions = {
// ...
};
export default config;
Configuration properties
To learn more about the application config properties, read the following.
name
The name of the Custom Application, for information purposes.
{
"name": "Channels app"
}
description
An optional description of the Custom Application, for information purposes.
{
"description": "Manage Channels"
}
entryPointUriPath
projectKey of the Composable Commerce APIs. This value determines the route at which the Custom Application is served by the Merchant Center Proxy./:projectKey/:entryPointUriPath
entryPointUriPath is important and should be done carefully as it affects routing and permissions.{
"entryPointUriPath": "channels"
}
entryPointUriPath value must adhere to the following restrictions:- Only lowercase alphanumeric characters are allowed.
- Must be between 2 and 64 characters.
- Underscores and hyphens are allowed except as leading, trailing, and adjacent characters.
entryPointUriPath value is bound to user permissions of the Custom Application and is used to derive the unique name of the user permissions.Some values are reserved for internal usage and cannot be used:
accountaudit-logdashboardcategorieschange-historycustomersexportsdiscountsoperationsimpeximportsimports-exportsordersproductssettingswelcomedisabledstandalone-prices
entryPointUriPath is a unique identifier of a Custom Application, and thus should be defined statically in the source code, it can also be defined dynamically via environment variables using the environment placeholders.This may be the case if the Custom Application is to be deployed in different environments.
cloudIdentifier
{
"cloudIdentifier": "gcp-eu"
}
mcApiUrl property to the Custom Application config file with the full origin URL.mcApiUrl
cloudIdentifier. Use this only if the cloudIdentifier does not contain a value for the environment you want to connect to.env
development or production. Which environment is used depends on the environment variable MC_APP_ENV. If MC_APP_ENV isn't set, NODE_ENV will be used. If neither is set, it defaults to development.MC_APP_ENV is useful if you want to run the production build of the Custom Application locally. In this case the NODE_ENV needs to be set to production. However, because the application runs locally, you need to have the URL references pointing to localhost, thus the MC_APP_ENV needs to be set to development.env.development.initialProjectKey
projectKey of a commercetools Project you have access to. To be used as the default Project upon login in development.{
"env": {
"development": {
"initialProjectKey": "my-project-key"
}
}
}
env.development.teamId
Administrators Team of your Organization with no additional configuration required.teamId of the user's team.env.production.applicationId
{
"env": {
"production": {
"applicationId": "ckvtahxl90097sys6har1e6n3"
}
}
}
As long as you are developing the Custom Application locally, you can define any random value as it's a required field.
env.production.url
{
"env": {
"production": {
"url": "https://channels.app"
}
}
}
env.production.cdnUrl
{
"env": {
"production": {
"cdnUrl": "https://cdn.channels.app"
}
}
}
env.production.url value will be used instead.additionalEnv
For example, if the Custom Application should reference an external API, or have links to certain support pages:
{
"additionalEnv": {
"trackingSentry": "https://000@sentry.io/000",
"channelsSupportUrl": "https://support.channels.app"
}
}
oAuthScopes
You can have "view-only" or "manage-only" OAuth Scopes and leave the other list field empty, as long as at least one OAuth Scope is specified.
oAuthScopes.view
View permission.{
"oAuthScopes": {
"view": ["view_states"]
}
}
oAuthScopes.manage
Manage permission.{
"oAuthScopes": {
"manage": ["manage_orders"]
}
}
manage_ OAuth Scopes always imply the corresponding view_ OAuth Scope.additionalOAuthScopes
21.21.0 onwards.additionalOAuthScopes.*.name
A unique name for the additional permission group.
{
"additionalOAuthScopes": [
{
"name": "movies"
}
]
}
The name value must adhere to the following restrictions:
- Only lowercase alphabetic characters are allowed.
- Must be between 2 and 64 characters.
- Hyphens are allowed except as leading, trailing, and adjacent characters.
additionalOAuthScopes.*.view
View<GroupName> permission.{
"additionalOAuthScopes": [
{
"name": "movies",
"view": ["view_products"],
"manage": []
},
{
"name": "merch",
"view": ["view_categories"],
"manage": []
}
]
}
additionalOAuthScopes.*.manage
Manage<GroupName> permission.{
"additionalOAuthScopes": [
{
"name": "movies",
"view": [],
"manage": ["manage_products"]
},
{
"name": "merch",
"view": [],
"manage": ["manage_categories"]
}
]
}
headers
An optional object to configure HTTP headers used by the Custom Application.
headers.csp
connect-srcfont-srcframe-srcimg-srcmedia-srcscript-srcstyle-src
*) to control from where certain types of content can be loaded or executed.{
"headers": {
"csp": {
"connect-src": ["https://api.stripe.com"],
"frame-src": ["https://js.stripe.com", "https://hooks.stripe.com"],
"script-src": ["https://js.stripe.com"]
}
}
}
cloudIdentifier and the env.production.url. This includes the hostname where the Custom Application is hosted and the hostname of the Merchant Center API Gateway.headers.permissionsPolicies
Permissions-Policy header.headers.permissionPolicies object is used only for local development. To enable these features for production, you need to instruct your hosting server to return the header with the modified values. The Merchant Center Proxy Router will then attempt to merge the values with the default ones.{
"headers": {
"permissionsPolicies": {
"microphone": "()",
"camera": "()",
"payment": "()",
"usb": "()",
"geolocation": "()"
}
}
}
headers.strictTransportSecurity
Strict-Transport-Security header.{
"headers": {
"strictTransportSecurity": ["includeSubDomains", "preload"]
}
}
icon
${path:}:{
"icon": "${path:@commercetools-frontend/assets/application-icons/<icon_name>.svg}"
}
bagbellboxchatcodeexportfilesfoldergiftglobegraphheadphonesimportlocationnetworkpercentagepricetagrocketscreensearchsettingsspecialstackstampstarstatstrolleytruckuserswrenchUse variable placeholders
Variable placeholders are a way of injecting certain information into the "static" configuration file.
Environment variable references
To make the application config more reusable across different environments, you can use references to environment variables within the application config file.
${} together with the prefix key env:. For example, to load an environment variable called APP_URL, you would use ${env:APP_URL}.${env:CLOUD_IDENTIFIER} reference to the field cloudIdentifier and pass the actual value using environment variables.{
"cloudIdentifier": "${env:CLOUD_IDENTIFIER}"
}
CLOUD_IDENTIFIER environment variable can be provided in various ways.For example:
-
as an inline environment variable when running a script command
CLOUD_IDENTIFIER=gcp-eu mc-scripts start -
using a dotenv file
CLOUD_IDENTIFIER=gcp-eumc-scripts --env .env-eu start -
by defining the environment variables in your CI service
You can also pass multiple references to the same value:
{
"additionalEnv": {
"authorityUrl": "https://${env:IDP_URL}/${env:IDP_ID}"
}
}
Intl message references
20.8.0 onwards.${} together with the prefix key intl:. For example, to load a translation message from the en.json file named Menu.Channels, you would use ${intl:en:Menu.Channels}.{
"mainMenuLink": {
"defaultLabel": "${intl:en:Menu.Channels}",
"labelAllLocales": [
{ "locale": "en", "value": "${intl:en:Menu.Channels}" },
{ "locale": "de", "value": "${intl:de:Menu.Channels}" }
]
}
}
The reference placeholder assumes that the Custom Application has the translation files in one of the following locations:
<app_root>/src/i18n/data/<locale>.json<app_root>/i18n/data/<locale>.json
File path references
20.8.0 onwards.${} together with the prefix key path:.icon of the Custom Application.{
"icon": "${path:./app.svg}"
}
You can use a path relative to the application folder or a path to a module.
{
"icon": "${path:@commercetools-frontend/assets/application-icons/rocket.svg}"
}
Runtime application environment
window.app.<ApplicationShell>.const EntryPoint = () => (
<ApplicationShell
environment={window.app}
// other props
/>
);
environment prop is parsed and injected into a React Context, making it available to the entire application. To access it, use the @commercetools-frontend/application-shell-connectors package.import { useApplicationContext } from '@commercetools-frontend/application-shell-connectors';
const MyComponent = () => {
const applicationName = useApplicationContext(
(context) => context.environment.applicationName
);
return <div>{`Welcome to the application ${applicationName}!`}</div>;
};
additionalEnv object are made available to the context.environment object.For more information, see Custom user properties.