Route /api/auth through the same origin in both dev and prod so cookies stay first-party and the browser and React Router SSR share one auth surface. - Vite dev server proxies /api/auth to the Convex HTTP site. - Better Auth uses secure cookies when the site URL is https. - Add docs/auth-proxy.md documenting the required production ingress (Caddy/Traefik) and Convex SITE_URL / CONVEX_SITE_URL setup.
24 lines
575 B
TypeScript
24 lines
575 B
TypeScript
import path from "node:path";
|
|
|
|
import { reactRouter } from "@react-router/dev/vite";
|
|
import tailwindcss from "@tailwindcss/vite";
|
|
import { defineConfig } from "vite-plus";
|
|
|
|
export default defineConfig({
|
|
envDir: path.resolve(import.meta.dirname, "../.."),
|
|
plugins: [tailwindcss(), reactRouter()],
|
|
resolve: {
|
|
dedupe: ["convex", "react", "react-dom"],
|
|
tsconfigPaths: true,
|
|
},
|
|
server: {
|
|
allowedHosts: true,
|
|
proxy: {
|
|
"/api/auth": {
|
|
changeOrigin: true,
|
|
target: "https://befitting-dalmatian-161.convex.site",
|
|
},
|
|
},
|
|
},
|
|
});
|