This document explains how to deploy the Entropy.Space marketing website alongside the backend API.
The website is a static React SPA that connects to your backend API via HTTP requests:
┌──────────────┐ HTTP ┌──────────────┐
│ Website │ ────────────────────> │ Backend │
│ (Static) │ /api/v1/health │ (FastAPI) │
│ React SPA │ /api/v1/stats │ Python │
│ │ /api/v1/random/{n} │ │
└──────────────┘ └──────────────┘
- GitHub account
- Vercel account (free tier is fine)
- Backend API already deployed (e.g., on Render)
-
Push Website to GitHub
cd website/solar-entropy-api-main/solar-entropy-api-main git add . git commit -m "Prepare website for deployment" git push
-
Connect to Vercel
- Go to https://vercel.com
- Click "Import Project"
- Select your GitHub repository
- Set root directory:
website/solar-entropy-api-main/solar-entropy-api-main
-
Configure Build Settings
- Framework Preset:
Vite - Build Command:
npm run build - Output Directory:
dist - Install Command:
npm install
- Framework Preset:
-
Add Environment Variables In Vercel dashboard → Settings → Environment Variables:
VITE_API_BASE_URL=https://your-backend.onrender.com/api/v1 VITE_STATS_POLL_INTERVAL=10000 -
Deploy
- Click "Deploy"
- Your site will be live at
https://<project-name>.vercel.app
-
Optional: Custom Domain
- Vercel dashboard → Domains
- Add your domain (e.g.,
entropy.space) - Update DNS records as instructed
-
Build the Website
cd website/solar-entropy-api-main/solar-entropy-api-main npm install npm run build -
Connect to Netlify
- Go to https://netlify.com
- Drag and drop the
dist/folder - Or connect via GitHub for auto-deploy
-
Configure Environment
- Site settings → Environment variables
- Add
VITE_API_BASE_URL
-
Configure Build
# netlify.toml [build] command = "npm run build" publish = "dist" base = "website/solar-entropy-api-main/solar-entropy-api-main" [[redirects]] from = "/*" to = "/index.html" status = 200
-
Create New Static Site
- Go to Render dashboard
- New → Static Site
- Connect your GitHub repo
-
Configure
- Root Directory:
website/solar-entropy-api-main/solar-entropy-api-main - Build Command:
npm install && npm run build - Publish Directory:
dist
- Root Directory:
-
Environment Variables
VITE_API_BASE_URL=https://your-backend.onrender.com/api/v1 -
Deploy
- Render will auto-build and deploy
- Live at
https://<site-name>.onrender.com
You can serve the website from the FastAPI backend, but this couples your frontend and backend.
-
Build Website
cd website/solar-entropy-api-main/solar-entropy-api-main npm run build -
Copy Build to Backend
cp -r dist/* ../../app/static/ -
Update FastAPI to Serve Static Files
# app/main.py from fastapi.staticfiles import StaticFiles app.mount("/", StaticFiles(directory="app/static", html=True), name="static")
-
Deploy Backend with Website Included
If your website and backend are on different domains, configure CORS in the backend:
# app/main.py
from fastapi.middleware.cors import CORSMiddleware
app.add_middleware(
CORSMiddleware,
allow_origins=[
"https://your-website.vercel.app",
"https://entropy.space", # Your custom domain
"http://localhost:8080", # Local development
],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)| Variable | Description | Example |
|---|---|---|
VITE_API_BASE_URL |
Backend API base URL | https://api.entropy.space/api/v1 |
VITE_STATS_POLL_INTERVAL |
Stats refresh interval (ms) | 10000 |
See main DEPLOYMENT.md for backend env vars.
-
Check Health Endpoint
curl https://your-website.com/api/v1/health
-
Test Playground
- Visit https://your-website.com
- Scroll to Playground
- Click "Generate"
- Verify random bytes are fetched
-
Verify Stats
- Check Hero section stats
- Confirm they update every 10 seconds
- Open browser console to check for errors
Problem: Browser console shows CORS errors
Solution: Add your website domain to backend CORS origins
Problem: "Failed to fetch" errors
Solution:
- Verify
VITE_API_BASE_URLis correct - Check backend is running and accessible
- Ensure backend has HTTPS (or both are HTTP)
Problem: npm install or build fails
Solution:
- Verify Node.js version (should be 16+)
- Check for TypeScript errors locally first
- Review deployment logs for specific error
Problem: Hero stats show default values
Solution:
- Check
/statsendpoint is working - Verify CORS allows cross-origin requests
- Inspect browser Network tab for failed requests
Most hosting platforms (Vercel, Netlify) handle this automatically.
Add cache headers for static assets:
# Example Nginx config
location /assets/ {
expires 1y;
add_header Cache-Control "public, immutable";
}Vercel and Netlify include CDN by default. For custom hosting, use Cloudflare.
If you add images:
npm install --save-dev vite-plugin-imagemin- HTTPS Only: Always use HTTPS in production
- Environment Variables: Never commit
.env.localto git - API Rate Limiting: Backend should enforce rate limits
- CORS Restrictive: Only allow your website domains
- No Secrets Client-Side: Never expose API keys or secrets in frontend code
Add to index.html:
<!-- Plausible Analytics -->
<script defer data-domain="entropy.space" src="https://plausible.io/js/script.js"></script>Add Sentry:
npm install @sentry/react// src/main.tsx
import * as Sentry from "@sentry/react";
Sentry.init({
dsn: "your-sentry-dsn",
environment: import.meta.env.MODE,
});- Free Tier: 100 GB bandwidth/month, unlimited projects
- Pro: $20/month (commercial projects)
- Free Tier: 100 GB bandwidth/month
- Pro: $19/month
- Static Site: Free with 100 GB bandwidth/month
All tiers are sufficient for small to medium traffic.
- Deploy backend first (see main
DEPLOYMENT.md) - Deploy website with backend URL configured
- Test all API integrations
- Add custom domain (optional)
- Enable analytics (optional)
- Add error tracking (optional)