> ## Documentation Index
> Fetch the complete documentation index at: https://help.noxity.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy Express

> Run an Express API on the Node.js Selector. Export the app, skip listen, configure routes.

Express is the easy case. Write your routes, export the app, let Passenger run it.

For the underlying tool, see [Node.js](/web-hosting/virtual-containers/nodejs).

## Before you begin

* A Node.js app created in cPanel.
* The app root contains your Express project with `package.json`.

## Wire up the export

<Steps>
  <Step title="Edit your entry file (default `app.js`)">
    ```js app.js theme={}
    const express = require('express');
    const app = express();

    app.use(express.json());

    app.get('/health', (_req, res) => res.json({ ok: true }));

    // your routes here

    module.exports = app;
    ```

    No `app.listen()`. Passenger handles that.
  </Step>

  <Step title="Install dependencies">
    Click **Run NPM Install** in the cPanel app management page.
  </Step>

  <Step title="Restart">
    Click **Restart**.
  </Step>
</Steps>

## Use environment variables

Express reads from `process.env`. Add variables in the cPanel UI under **Environment variables**, then restart for them to take effect:

```js theme={}
const dbUrl = process.env.DATABASE_URL;
const apiKey = process.env.STRIPE_SECRET;
```

## Common issues

<AccordionGroup>
  <Accordion title="POST requests return an empty body">
    Add the JSON parser middleware: `app.use(express.json())`. For form data: `app.use(express.urlencoded({ extended: true }))`.
  </Accordion>

  <Accordion title="CORS errors from a frontend on a different domain">
    Install `cors`, mount before your routes:

    ```js theme={}
    const cors = require('cors');
    app.use(cors({ origin: 'https://your-frontend.example' }));
    ```
  </Accordion>
</AccordionGroup>

## Need a hand?

<CardGroup cols={2}>
  <Card title="Open a ticket" icon="life-ring" href="https://members.noxity.io/submitticket.php">
    Best for anything that needs an account check or a config change on our end.
  </Card>

  <Card title="Live chat" icon="messages" href="https://noxity.io/contact">
    Faster for quick questions during business hours.
  </Card>
</CardGroup>
