Edgio
Edgio

layer0.config.js

The layer0.config.js config file in your app’s root directory contains configuration options that control how your app runs on Layer0. This file is automatically created when you run 0 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 but you can specify any other acceptable port value. Note that specifying 80 has no special meaning as Layer0 will never send secured requests to unsecured backends. To enable HTTP traffic on a backend you must have a route matching http protocol in your router and serve content from that route. All HTTP traffic assumes port 80 on the backend.

connector

The name of the connector package corresponding to the framework your app uses, or the path to a directory that implements the connector interface.

Example

To use a connector package:

JavaScript
module.exports = {
  connector: '@layer0/next',
};

To implement a connector directly within your project:

JavaScript
// this directory should have build.js, prod.js, and dev.js
module.exports = {
  connector: './path/to/connector/dir'
};

routes

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

includeNodeModules

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

includeFiles

Allows you to include additional resources in the bundle that is deployed to Layer0’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

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

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

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

prerenderConcurrency

The maximum number of URLs that will be concurrently prerendered during deployment when static prerendering is enabled. Defaults to 200, which is the maximum allowed value.

sources

A list of glob patterns identifying which source files should be uploaded when running 0 deploy --includeSources. This option is primary used to share source code with Layer0 support personnel for the purpose of debugging. If omitted, 0 deploy --includeSources will result in all files which are not gitignored being uploaded to Layer0.

Example:

JavaScript
sources: [
  '**/*', // include all files
  '!(**/secrets/**/*)', // except everything in the secrets directory
]

Example layer0.config.js

JavaScript
// This file was automatically added by layer0 deploy.
// You should commit this file to source control.
module.exports = {
  backends: {
    origin: {
      // The domain name or IP address of the origin server
      domainOrIp: "example.com",

      // When provided, the following value will be sent as the host header 
      // when connecting to the origin. If omitted, the host header from 
      // the browser will be forwarded to the origin.
      hostHeader: "example.com",

      // Uncomment the following line if TLS is not set up properly on the 
      // origin domain and you want to ignore TLS errors
      disableCheckCert: true,

      // Overrides the default ports (80 for http and 443 for https) and 
      // instead use a specific port when connecting to the origin
      port: 1337,
    },
  },

  // The name of the site in Layer0 to which this app should be deployed.
  name: "example.com",

  // The name of the team in Layer0 to which this app should be deployed.
  team: 'my-team-name',

  // Overrides the default path to the routes file. The path should be relative 
  // to the root of your app.
  routes: 'routes.js',

  // The maximum number of URLs that will be concurrently prendered during 
  // deployment when static prerendering is enabled. Defaults to 200, which is 
  // the maximum allowed value.
  prerenderConcurrency: 200,

  // A list of glob patterns identifying which source files should be uploaded 
  // when running layer0 deploy --includeSources. This option is primarily used 
  // to share source code with Layer0 support personnel for the purpose of 
  // debugging. If omitted, layer0 deploy --includeSources will result in all 
  // files which are not gitignored being uploaded to Layer0.
  //
  sources : [
     '**/*', // include all files
     '!(**/secrets/**/*)', // except everything in the secrets directory
  ],

  // Set to true to include all packages listed in the dependencies property 
  // of package.json when deploying to Layer0.  This option generally isn't 
  // needed as Layer0 automatically includes all modules imported by your 
  // code in the bundle that is uploaded during deployment
  //
  includeNodeModules: true,
};