Instead of the complex Cloudflare Worker setup with CORS proxy, you can now deploy both PWA and backend on Uberspace (~5€/month). Changes: - Add Express.js backend server (server/index.js) - Update ConfigService to support VITE_API_URL env variable - Make base path configurable via VITE_BASE_PATH - Add comprehensive Uberspace deployment guide - Add .env.production.example for configuration Deployment options: 1. Uberspace (recommended): Simple, all-in-one hosting 2. GitHub Pages + Cloudflare Workers: Free but complex setup Co-Authored-By: Claude <noreply@anthropic.com>
40 lines
942 B
TypeScript
40 lines
942 B
TypeScript
import react from "@vitejs/plugin-react";
|
|
import { defineConfig } from "vite";
|
|
import { handleSteamRefresh, handleConfigLoad } from "./server/steam-api.mjs";
|
|
import { handleGameAsset } from "./server/assets-api.mjs";
|
|
|
|
const apiMiddlewarePlugin = {
|
|
name: "api-middleware",
|
|
configureServer(server) {
|
|
server.middlewares.use((req, res, next) => {
|
|
const url = req.url ?? "";
|
|
if (url.startsWith("/api/steam/refresh")) {
|
|
return handleSteamRefresh(req, res);
|
|
}
|
|
if (url.startsWith("/api/config/load")) {
|
|
return handleConfigLoad(req, res);
|
|
}
|
|
if (url.startsWith("/api/games/")) {
|
|
return handleGameAsset(req, res);
|
|
}
|
|
next();
|
|
});
|
|
},
|
|
};
|
|
|
|
export default defineConfig({
|
|
// GitHub Pages: /whattoplay/
|
|
// Uberspace: /
|
|
base: process.env.VITE_BASE_PATH || "/whattoplay/",
|
|
plugins: [react(), apiMiddlewarePlugin],
|
|
server: {
|
|
port: 5173,
|
|
hmr: {
|
|
overlay: true,
|
|
},
|
|
watch: {
|
|
usePolling: true,
|
|
},
|
|
},
|
|
});
|