We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Can I deploy my Remix + Express (Node.js) Shopify app on a single server?

Can I deploy my Remix + Express (Node.js) Shopify app on a single server?

damonrcr
Shopify Partner
19 0 3

Hi everyone,

I’m building a Shopify app where:

  • The frontend and authentication (including Prisma-based session handling) are built using Remix.

  • The backend APIs are built separately using Node.js, Express, and Mongoose.

  • For development:

    • I run the Remix app using npm run dev (handles Shopify app install and session).

    • I run the backend APIs using npm run server.

My question is:
Do I need two separate servers for deployment, or is it possible to deploy both the Remix app and the Express API on a single server?
If it’s possible to run everything on one server, what’s the best way to do that?

 

This is my backend server code:

import dotenv from "dotenv";
dotenv.config();
import express from "express";
import cors from "cors";
import { connectDB } from "./config/db.js";


const app = express();
const port = process.env.PORT || 8000;
console.log("env DB URL from index.js:", process.env.DATABASE_URL);

app.use(express.json());
app.use(express.urlencoded());

// Configure CORS properly
app.use(cors({
  origin: '*',
  methods: ['GET', 'POST', 'PUT', 'DELETE'],
  allowedHeaders: ['Content-Type', 'Authorization'],
}));

// MongoDB Connection
connectDB();

// Routes import
import VerficationSettingRoutes from "./routes/verification.routes.js";
import planRoutes from './routes/plan.routes.js';
import verificationLogRoutes from "./routes/verificationLog.routes.js";
import analyticsRoutes from "./routes/analytics.routes.js";
import supportRoutes from "./routes/support.routes.js";
import ocrRoutes from "./routes/upload.routes.js";
import toggleRoutes from "./routes/toggle.routes.js";


// Routes declaration
app.use('/api/v1', VerficationSettingRoutes);
app.use('/api/v1', planRoutes);
app.use('/api/v1', verificationLogRoutes);
app.use('/api/v1', analyticsRoutes);
app.use('/api/v1', supportRoutes);
app.use('/api/v1', ocrRoutes);
app.use('/api/v1', toggleRoutes);




// Global Error Handler (for better error responses)
app.use((err, req, res, next) => {
  console.error("Error:", err);
  res.status(500).json({ error: "Internal Server Error", details: err.message });
});

app.listen(port, () => {
  console.log(`Server running on port ${port}`);
});

I’d really appreciate guidance from anyone who has handled a similar setup. Thank you!

Reply 1 (1)
damonrcr
Shopify Partner
19 0 3

Thanks so much @Marco002  for the clarification—this makes a lot of sense! 🙌

Yes, I’d really appreciate it if you could share a sample setup that shows how to serve both the Remix app and Express API on a single server using middleware. An example with directory structure and how routing is handled between Remix and custom API routes would be super helpful.

Looking forward to seeing how you'd structure it!

Thanks again! 🙏