Skip to main content
Version: 3.x

config

Config related methods

defineConfig

The defineConfig method allows to configure the Front-Commerce application.

The method takes a UserConfig object as parameter. It can either be an object, a function that return an UserConfig or a Promise that resolve an UserConfig.

front-commerce.config.ts
import { defineConfig } from "@front-commerce/core/config";
import themeChocolatine from "@front-commerce/theme-chocolatine";
import magento2 from "@front-commerce/magento2";
import storesConfig from "./app/config/stores";
import cacheConfig from "./app/config/caching";

export default defineConfig({
extensions: [magento2({ storesConfig }), themeChocolatine()],
stores: storesConfig,
cache: cacheConfig,
configuration: {
providers: [],
},
v2_compat: {
useApolloClientQueries: true,
},
});

createConfigFromRequest

Create a configuration from request.

danger

This is an internal API, we recommend you to use the Front-Commerce context to retrieve configuration information

UserConfig

extensions

Optional List of extensions to load

stores

Required Store configuration

import { defineConfig } from "@front-commerce/core/config";
import storesConfig from "./app/config/stores";
import cacheConfig from "./app/config/caching";

export default defineConfig({
extensions: [],
stores: storesConfig,
cache: cacheConfig,
configuration: {
providers: [],
},
});

cache

Required Your cache configuration

import { defineConfig } from "@front-commerce/core/config";
import storesConfig from "./app/config/stores";
import cacheConfig from "./app/config/caching";

export default defineConfig({
extensions: [],
stores: storesConfig,
cache: cacheConfig,
configuration: {
providers: [],
},
});

configuration

Object that define app configuration

serverEvents

This configuration allow you to use server events in your Front-Commerce application, please follow the Server Events Documentation to learn more about this.

Configuration for server events:

app/config/serverEvents.ts
export default {
redis: {
host: "127.0.0.1", // Host of the Redis server for subscription
port: 6379, // Port of the Redis server for subscription
},
integrations: [], // Integrations that should be loaded for server event
};
front-commerce.config.ts
import { defineConfig } from "@front-commerce/core/config";
import storesConfig from "./app/config/stores";
import cacheConfig from "./app/config/caching";
import serverEvents from "./app/config/serverEvents";

export default defineConfig({
extensions: [],
stores: storesConfig,
cache: cacheConfig,
serverEvents: serverEvents,
configuration: {
providers: [],
},
});

providers

List of configuration providers to register in the application.

v2_compat

Object that define V2 Compatible flags to use.

danger

This flags are provided here for compatibility with V2 project. If you start a new project with V3, you should not use this flags.

useApolloClientQueries

Whether the Apollo Client is still used to query data or not. Enables some fixes to ensure React 18 compatibility for old apollo-client versions.

useApolloClientSSR

Whether the SSR should honor Apollo Client queries or not. When using useApolloClientQueries, this flag determines whether the SSR should await for these queries resolution to render the application or not. Enabling this flag will ensure 2.x compatibility regarding SSR, but increases the Time To First Byte of the application.

rateLimiter

When defined the rate limiter service will be enabled.

import { defineConfig } from "@front-commerce/core/config";

export default defineConfig({
// ...other configuration options
rateLimiter: {
redis: {
host: process.env.FRONT_COMMERCE_CLOUD_REDIS_SESSIONS_HOST,
port: process.env.FRONT_COMMERCE_CLOUD_REDIS_SESSIONS_PORT || 6379,
db: process.env.FRONT_COMMERCE_CLOUD_REDIS_SESSIONS_DB || 2,
},
},
});

maintenance

This configuration allows you to customise various aspects of the MaintenanceMode service:

front-commerce.config.ts
import { defineConfig } from "@front-commerce/core/config";
import storesConfig from "./app/config/stores";
import cacheConfig from "./app/config/caching";

export default defineConfig({
extensions: [],
stores: storesConfig,
cache: cacheConfig,
maintenance: {
// All the options are optional
force: false, // Force the application to be in maintenance mode
authorizedIps: [], // List of authorized IPs that can access the application while in maintenance mode
memoizedInMS: 3600000, // Duration in milliseconds for the maintenance mode check to be memoized instead of being read from Redis (defaults to 5 seconds)
healthChecks: {
disabled: false, // Force disable health checks
schedule: "*/5 * * * * *", // Cron schedule to run health checks (defaults to every 5 seconds)
leaderCheckInterval: 10000, // Interval in which multi-instance leader checks are performed for health checks (defaults to 10 seconds)
},
},
});