feat: add optional CDN URL configuration for static assets in Vite

This commit is contained in:
Victor Santos
2025-12-12 08:47:54 -03:00
parent 05ad73756a
commit 9fae065e24

View File

@@ -29,7 +29,14 @@ export default defineConfig(({ mode }) => {
"0.0.1"
).replaceAll(".", "-");
// Optional CDN URL for static assets (e.g., https://cdn.example.com)
// When set, all static assets will be served from this URL instead of the same origin.
// This is useful for serving assets from a CDN subdomain while keeping API calls on the main domain.
// If not set, assets are served from the same origin (backward compatible).
const cdnUrl = env.VITE_CDN_URL || "";
return {
base: cdnUrl || "/",
server: {
allowedHosts,
host: true,