Hey devs π,
Iβve been building full-stack apps for years, and one thing always annoyed me:
Why are we still manually setting up proxies, fixing CORS, remembering build folders, and running two servers⦠just to connect a frontend and backend?
So I built a solution.
β‘ express-auto-frontend β Zero-Config Frontend + Express Integration
This small library automatically connects any modern frontend (React, Vite, Vue, Angular, Svelte, Nuxt, or even static HTML) to your Express backend β in both development and production.
π No proxy configs
π No CORS issues
π No remembering build paths
π No custom scripts
π No double-server headaches
Just one line:
include(app, '../frontend');
β¦and everything works.
π― Why I Built It
I kept seeing the same frustrations:
- Frontend on 5173, backend on 3001
- Vite proxy issues
- Random CORS errors
- Different dev vs production setups
- Confusing deployment steps
I wanted something that just works, with one unified URL during development and a clean production flow.
Now it does.
π‘ What It Automatically Handles
β Development Mode
- Detects your frontend framework
- Starts the frontend dev server automatically
- Proxies
/api/*requests to Express - Sends all other routes to the frontend dev server
- Full HMR support
- Eliminates CORS completely
- One single origin for the entire stack
β Production Mode
- Detects your
dist/buildfolder - Serves the optimized frontend build
- Handles SPA routing (
index.htmlfallback) - Express continues serving your API normally
Zero config. Zero stress.
π§ͺ Example (Complete App in 20 Seconds)
const express = require('express');
const include = require('express-auto-frontend');
const app = express();
const PORT = 3001;
app.get('/api/message', (req, res) => {
res.json({ message: 'Hello from the backend!' });
});
include(app, '../frontend');
app.listen(PORT, () =>
console.log(`Server running at http://localhost:${PORT}`)
);
Thatβs literally all you need.
π Supported Frameworks
- React (Vite + CRA)
- Vue (CLI + Nuxt)
- Angular
- Svelte / SvelteKit
- Static HTML or Pug
π¦ NPM
npm i express-auto-frontend
Package: express-auto-frontend
Current version: 1.0.2
Published: 15 hours ago
β€οΈ Final Words
I built this because full-stack development should feel smooth, not painful.
If youβre tired of manually setting up proxies, fighting CORS, and juggling two servers, give it a try.
If you want to reach out, collaborate, or share feedback, contact me at:
π© silivestirassey@gmx.com
Happy hacking! β‘
β Silivestir / splannes
Top comments (0)