Development

Localhost dev server

The aio-cli includes a development server for seamless local development, so you can run, develop, and test your applications on localhost. Traffic is securely served over HTTPS using a self-signed certificate. The server supports hot reloading, so you can instantly see the effects of any changes made to your application.

Note: as is common with self-signed certificates, you may need to accept 'unsafe site' warnings explicitly, and manually trust the certificate in your browser settings.

aio app dev vs. aio app run

These commands are very similar, but their differences give you different ways of working with your application. Both commands:

When you use the command aio app run, the following events occur before the localhost webserver is started:

When you use the command aio app dev:

State-lib and Files-lib usage

There are also differences in what your actions can do in these cases. The storage libraries have security restrictions that limit calls from outside Runtime actions, so if your action needs either state or files libs, it will fail with aio app dev. Third-party APIs may have similar restrictions.

Debugging

This section covers how to debug your App Builder application front-end and back-end code with full source maps support using VS Code Debugging or Chrome DevTools.

Note: although any debugger that can attach to Node.js can technically be used to debug App Builder applications, some of the details will differ from the configurations covered here. For details on node debugging see the Node.js Debugging Guide

Debugging with VS code

Create a file named .vscode/launch.json at the root of your project with this content:

{
  "version": "0.3.0",
  "configurations": [
    {
      "name": "App Builder: debug actions",
      "type": "node-terminal",
      "request": "launch",
      "command": "aio app dev",
      "skipFiles": [
        "<node_internals>/**/*.js",
        "${workspaceFolder}/node_modules/**/*.js"
      ]
    }, {
      "name": "App Builder: debug full stack",
      "type": "node-terminal",
      "request": "launch",
      "command": "aio app dev",
      "sourceMapPathOverrides": {
        "/__parcel_source_root/*": "${webRoot}/*"
      },
      "skipFiles": [
        "<node_internals>/**/*.js",
        "${workspaceFolder}/node_modules/**/*.js"
      ],
      "serverReadyAction": {
        "pattern": "server running on port : ([0-9]+)",
        "uriFormat": "https://localhost:%s",
        "action": "debugWithChrome",
        "webRoot": "${workspaceFolder}"
      }
    }
  ]
}

Note: The debug configuration is dynamic and allows you to set a port in the .env file, for example PORT=3000

Actions are loaded dynamically, so the code is not evaluated until an http request is made. This means breakpoints in your action code will be grayed out until you trigger a call to the action. Web action urls are mapped to https://localhost:PORT/api/v1/web/<package-name>/<action-name> and can be called from your front end, opening the url in your browser, with cURL, etc.

You can use the step-through debugging features of VS Code, inspect variables, add watches, etc.

Secure actions

The aio app dev command simulates Adobe authentication (i.e. require-adobe-auth annotation). If your actions are secured with require-adobe-auth: true, you will have to include both Authorization and x-gw-ims-org-id headers in your requests. Any value will work.

More information

Learn more about using a JavaScript debugger

Next step

Return to Guides Index.