xdn.config.js

The xdn.config.js config file in your app's root directory contains configuration options that control how your app runs on the Moovweb XDN. This file is automatically created when you run xdn init. It should export an object with the following properties:

backends

The backends config is an object whose keys are backend names and whose values are:

PropertyTypeDescription
domainOrIpString(Required) The domain or ip address for the backend site or API.
hostHeaderStringA value to send as the host header when sending requests to the backend site or API. By default the host header sent from the browser is used.
disableCheckCertBooleanA flag to turn off the TLS certificate check when making proxy requests to the backend site or API. By default it is false and for security purposes we strongly recommend that it is kept false in production environments. When using this option, you may also want to run your app with the NODE_TLS_REJECT_UNAUTHORIZED environment variable set to "0" to allow node to fetch from sites with invalid certificates.
portNumberThe port on which the backend receives https requests. Defaults to 443

routes

The path to your routes file relative to the root of your app. Defaults to routes.js.

server

Allows you to configure a custom server used to run your JavaScript functions in the cloud. The value is an object with two properties:

  • path - The path to the custom server module
  • export - The name of the export. You don't need to specify this if using export default.

The custom server module must export a function which accepts a http.ClientRequest and an http.ServerResponse. An Express Application can also be used here.

Example

// xdn.config.js

module.exports = {
  server: {
    path: '/server/server.js',
  },
}
// server/server.js

export default function(req, res) {
  // send a response and call res.end()
}

includeNodeModules

If true, the packages listed in the dependencies property of package.json will be included in the build that is deployed to the Moovweb XDN.

includeFiles

Allows you to include additional resources in the bundle that is deployed to the Moovweb XDN's serverless JS workers. Keys are globs, value can be a boolean or string. This is typically used to ensure that resources that need to be dynamically required at runtime such as build manifests for server-side rendering or other config files are present in the cloud.

Examples

includeFiles: {
  'lang/**/*': true,
},

or if you need to copy into a specific directory within the XDN build:

includeFiles: {
  'lang/**/*': 'another/dir/in/xdn/lambda',
},