
Security News
NIST Officially Stops Enriching Most CVEs as Vulnerability Volume Skyrockets
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.
express-auto-frontend
Advanced tools
Effortlessly connect and serve any modern frontend (React, Vue, Angular, Svelte) with your Express backend in development and production.
# express-auto-frontend
[](https://badge.fury.io/js/express-auto-frontend)
Effortlessly connect and serve any modern frontend (React, Vue, Angular, Svelte) with your Express backend in development and production.
---
## Why Express Auto Frontend?
Developers often face repetitive tasks when connecting a frontend and backend:
- Manually setting up proxies for dev servers
- Handling CORS issues
- Remembering frontend build paths
- Writing separate deployment scripts
`express-auto-frontend` **automates all of this**, giving you a seamless full-stack development experience.
---
## Advantages
- **Automatic Detection:** Detects your frontend framework (React, Vue, Angular, Svelte, Nuxt, or static files).
- **Zero-Config Dev Proxy:** Automatically proxies API requests to your backend during development.
- **Production Ready:** Serves optimized static builds with SPA routing support.
- **Framework Agnostic:** Works with all major modern frontends and static sites.
- **Unified Development Workflow:** One server to run, one URL to access, no CORS headaches.
---
## Use Case Scenario
Imagine you have a React frontend built with Vite and an Express API backend. Traditionally, you'd:
1. Start your Express server on port 3000
2. Start the React dev server on port 5173
3. Configure a proxy in `vite.config.js` to send API calls to Express
4. Deal with CORS issues in production builds
With `express-auto-frontend`:
1. You just call `include(app, '../frontend')` in your Express server
2. The frontend is automatically detected
3. Dev server starts and proxies are automatically configured
4. Production build is served from Express
All of this **without additional configuration**.
---
## Installation
```bash
npm install express-auto-frontend
server.js
const express = require('express');
const include = require('express-auto-frontend');
const app = express();
const PORT = 3001;
// API routes
app.get('/api/message', (req, res) => {
res.json({ message: 'Hello from the backend!' });
});
// Automatically include frontend (detects React, Vue, Angular, Svelte, or static)
include(app, '../frontend');
app.listen(PORT, () => {
console.log(`Server running on http://localhost:${PORT}`);
});
What happens now:
/api/* routes go to Express, everything else goes to frontend dev server./api/*) are proxied to Express./*) are proxied to the frontend dev server.npm run build outputs static files (dist/build).index.html.Optional config object as the third argument:
include(app, '../frontend', {
backendPort: 3001, // Required for proxying
devPort: 8080, // Override frontend dev server port
buildDir: 'build', // Override build directory
devScript: 'start' // Override npm dev script
});
| Framework | Dev Port | Build Dir | Dev Script |
|---|---|---|---|
| React (Vite) | 5173 | dist | dev |
| Vue (CLI) | 8080 | dist | serve |
| Angular | 4200 | dist/project-name | start |
| SvelteKit | 5173 | build | dev |
MIT
## **🔧 Development Workflow**
┌──────────────────────────┐ │ Browser (User) │ └───────────────┬──────────┘ │ Frontend Requests (/, /assets, etc.) │ ▼ ┌──────────────────────┐ │ Frontend Dev Server │ │ (React/Vue/Angular/ │ │ Svelte, etc.) │ └──────────┬───────────┘ │ Hot Reload / HMR │ ─────────────────┼──────────────────────────── │ API Requests (/api/*) │ ▼ ┌──────────────────────┐ │ Express Backend │ │ (API + Proxying) │ └──────────────────────┘
### **How it works in dev:**
* Browser requests **frontend UI** → sent to the **frontend dev server** (Vite/Webpack/Angular CLI).
* Browser requests **`/api/...`** → Express backend handles them.
* Express proxies UI requests to frontend dev server automatically.
* Full hot-reloading & unified origin → **no CORS needed**.
---
## **🚀 Production Workflow**
┌──────────────────────────┐ │ Browser (User) │ └───────────────┬──────────┘ │ All UI Requests (/, /js/, /css/) │ ▼ ┌──────────────────────┐ │ Express Serves Built │ │ Frontend (dist/ │ │ build/ production) │ └──────────┬───────────┘ │ SPA Fallback (index.html) ─────────────────┼──────────────────────────── │ API Requests (/api/*) │ ▼ ┌──────────────────────┐ │ Express Backend │ │ (API Only) │ └──────────────────────┘
### **How it works in production:**
* Browser requests the UI → Express serves files from `dist` / `build`.
* Client-side routing works using **index.html fallback**.
* `/api/*` is handled normally by Express.
* No dev server is running.
---
## **✨ Combined Architecture Overview**
┌─────────────────────────┐
│ express-auto-frontend │
│ (Middleware) │
└───────────┬────────────┘
│ Auto-detects framework
┌───────────────┼────────────────┬─────────────────────┐
▼ ▼ ▼ ▼
React Project Vue Project Angular Project Svelte/SvelteKit (Vite/CRA) (Vue CLI/Nuxt) (ng CLI) (Kit)
┌─────────────────────────────┐
│ Development Mode │
│ - Runs Dev Server │
│ - Proxies automatically │
└───────────────┬─────────────┘
│
▼
Unified Server
http://localhost:<backendPort>
┌──────────────────────────────┐
│ Production Mode │
│ - Serves static build │
│ - Handles SPA fallback │
└──────────────────────────────┘
FAQs
Effortlessly connect and serve any modern frontend (React, Vue, Angular, Svelte) with your Express backend in development and production.
The npm package express-auto-frontend receives a total of 1 weekly downloads. As such, express-auto-frontend popularity was classified as not popular.
We found that express-auto-frontend demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.