This guide moves an existing MERN app (MongoDB, Express, React, Node) to a FlyNode Cloud Workspace. Your Node and Express server runs as a Custom app, and FlyNode creates the MongoDB next to it with the connection already set.
How the pieces fit
- Express API and React front end: one Custom app. The simplest setup is to let Express serve the built React files, so you deploy one app instead of two.
- MongoDB: a database FlyNode creates with your app. Only your own apps on FlyNode can reach it, and it does not count toward your workspace's app limit. FlyNode sets
MONGODB_URIandMONGO_URLon your app before its first start.
Before you start
- Your code is in a repository on GitHub, GitLab or Bitbucket. For a private repository, read Deploy a Private Repository first.
- Your app starts with one command, usually
npm start, and reads its database address from an environment variable such asMONGODB_URI. - You have a list of the other variables the app reads: JWT or session secrets, API keys, and the public address of your front end.
The fast way: let Claude do it
If you use Claude, it can do the deploy for you. Connect it once with Deploy and Migrate with Claude or the CLI, then:
- Push your project to GitHub.
- Tell Claude: Deploy this app to FlyNode with MongoDB.
- Claude gives you a private link. Open it and paste your secrets there. They never go through the chat.
- Open the live address Claude gives you.
Prefer the terminal? In your project folder run:
flynode deploy --db mongodb
FlyNode sets MONGODB_URI (and MONGO_URL) for you, so make sure your server reads one of them. Send your other variables with flynode env push.
Step 1: Get the code ready
Listen on the port FlyNode gives you. Your container is given port 3000 and PORT is set to it. If your server reads process.env.PORT, nothing changes. If the port is written into the code, change it:
const port = process.env.PORT || 3000;
app.listen(port, () => console.log('Listening on ' + port));
Serve the React build from Express and send every other route to index.html, so a page refresh on a React route does not return a 404. Put this after your /api routes (Vite builds to dist instead of build):
const path = require('path');
app.use(express.static(path.join(__dirname, 'client', 'build')));
app.get('*', (req, res) =>
res.sendFile(path.join(__dirname, 'client', 'build', 'index.html')));
Add a build script at the top level. FlyNode reads the package.json in the root of the repository, so a root script that installs and builds the client is enough:
"scripts": {
"build": "npm install --prefix client && npm run build --prefix client",
"start": "node server/index.js"
}
Step 2: Deploy the app with its database
- Go to Deploy and choose Custom app.
- Enter an app name, choose Public repository or Private repository, paste the repository address and check the branch.
- In the Database section press MERN or Express with Mongoose. It ticks MongoDB. Leave Advanced build options empty first, because FlyNode detects Node projects on its own.
- Press Continue, keep the generated domain, press Continue again and then Deploy App.
The database is created first and its variables are set before the app starts, so the very first build already has them. You can also add a database to a running app: open the app, go to the Database tab and press the database you need.
Step 3: Move your data
- On your own computer, take a dump of the old database with MongoDB's own tool:
mongodump --uri "OLD_CONNECTION_STRING" --archive=app.archive.gz --gzip. - Open the app, go to Database, find the MongoDB card and press Choose a file under Import a dump. Pick the
.archive.gzfile. The limit is 500 MB. - Tick Replace everything in the database first if you want the new database to match the dump exactly. Without it the data is added to what is already there.
- FlyNode loads the file in the background and shows the result under the button. Check that your collections and counts match.
The same card has Download for a dump you can keep, and FlyNode backs the database up every night with the app (see the app's Backup tab). If your data is bigger than 500 MB, or you want to stay on a provider such as Atlas, pick No database and set MONGODB_URI yourself in the next step.
Step 4: Add your other variables
Open the app, go to Settings and then Variables. The database variables are already there. Add the rest (secrets, API keys, your public address), then press Save and redeploy. A variable is read when the app starts, so it only takes effect after a deploy. Paste a .env reads a whole file at once.
For more on variables, see Build Logs, Environment Variables and Rollback.
Step 5: Check that it works
- Settings, then Deploys should show your build as Succeeded. If it failed, press View log to read why.
- The Logs tab shows what your app prints. Look for your own start message.
- Open the app's address and try a login and one page that reads from the database.
Step 6: Use your own domain
Add your domain from the app's Custom Domain tab and follow Custom Domains for Your Apps. After it is live, update the places that still point at the old address: the API address your React code calls, the allowed origin in your CORS settings, and any webhook or OAuth callback addresses.
If something goes wrong
- The build fails. Open Deploys and press View log. A missing build script or a wrong folder is the usual cause. Set the install, build and start commands by hand under advanced options.
- The app shows Running but the address does not open. The app is probably not listening on
PORT. Check the Logs tab. - The app crashes right after starting. Read the Logs tab. Check that your code reads
MONGODB_URI(orMONGO_URL), the names FlyNode sets. - The import says the database refused the file. Use a file made with
mongodump --archive(add--gzipfor a smaller file). A folder-style dump is not accepted. - Uploaded files disappear after a deploy. A deploy builds a new container, so files written at run time are not kept. Store uploads in object storage such as S3.
Next steps
- Deploy a Private Repository and redeploy on every push.
- Using the Terminal and Logs.
Still stuck?
Open a support ticket from your dashboard and include the container name.