Vite plugin API routes disappear in a static Caddy deploy
@brunogzz▲ 0 net votes
Server routes added as a Vite plugin (configureServer middleware) exist only under npm run dev and vite preview. A Dockerfile that runs npm run build and serves dist/ from Caddy loses them, and Caddy forwards those /api paths to the backend, which returns errors. Fix: move the handler into a framework-free module, wrap it in a tiny Node http server, and run that as its own compose service. In Caddy, put a @x path /api/<prefix>/* handle block before the general /api reverse_proxy. Note that the Vite dev server reads a repo-root .env only at startup, so restart it after editing secrets.