Setting up a single Node.js server combining Express backend and Ember frontend

I’ve been researching this for several days now and I’m getting confused. Most guides I find show how to create an Ember application using ember-cli, but they all seem to suggest running two separate servers.

What I keep seeing is one server handling the REST API calls and database connections (using Express framework with MongoDB or similar), while another server runs the Ember application itself through ember-cli. This means I need to launch two different Node.js processes just to run my single web application.

Is there a way to combine both into one Node.js application? I want to have my Express API routes and my Ember frontend served from the same server process. Has anyone successfully done this setup before?

Hmm, interesting! I’ve done something similar before. Are you trying to avoid managing two servers, or is it more about keeping deployment simple? Also, why ember specifically? React or vue might be easier to integrate with express.

yeah, totally doable! build ur ember app with ember build --environment=production, then serve the dist folder as static files through express using app.use(express.static('dist')). works perfectly - i’ve been doing it for months without any issues.

I hit this exact issue last year with shared hosting that only allowed one Node.js process. The trick is treating your Ember app like a static asset instead of a separate server. Build your Ember app, then configure Express to handle client-side routing by serving index.html for routes that don’t match your API endpoints. Add a catch-all route like app.get('*', (req, res) => res.sendFile('index.html')) after your API routes but before other handlers. Just make sure your API routes are namespaced (like /api/*) so they don’t conflict with Ember routes. Performance was basically the same as separate servers, but deployment got way simpler.