Enhance Docker and Vite configurations for marketing service; update allowed hosts in docker-compose; modify marketing script in package.json; fix heading typo in Usage component; update marketing image asset.

This commit is contained in:
IGNY8 VPS (Salman)
2025-11-13 19:54:22 +00:00
parent 0b1445fdc9
commit f8bab8d432
6 changed files with 90 additions and 35 deletions

View File

@@ -110,6 +110,7 @@ services:
- "0.0.0.0:8023:5174" # Marketing dev server port (internal: 5174, external: 8023) - "0.0.0.0:8023:5174" # Marketing dev server port (internal: 5174, external: 8023)
environment: environment:
VITE_BACKEND_URL: "https://api.igny8.com/api" VITE_BACKEND_URL: "https://api.igny8.com/api"
VITE_ALLOWED_HOSTS: "igny8.com,www.igny8.com,app.igny8.com,api.igny8.com,localhost,127.0.0.1,0.0.0.0,172.18.0.13"
volumes: volumes:
- /data/app/igny8/frontend:/app:rw - /data/app/igny8/frontend:/app:rw
networks: [igny8_net] networks: [igny8_net]

View File

@@ -5,7 +5,7 @@
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"dev:marketing": "vite --host 0.0.0.0 --port 5174 --mode development --force marketing.html", "dev:marketing": "PORT=5174 vite --host 0.0.0.0 --port 5174 --mode development",
"build": "vite build", "build": "vite build",
"build:marketing": "vite build --mode marketing", "build:marketing": "vite build --mode marketing",
"build:check": "tsc -b && vite build", "build:check": "tsc -b && vite build",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 351 KiB

After

Width:  |  Height:  |  Size: 363 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 363 KiB

View File

@@ -71,7 +71,7 @@ export default function Usage() {
<div className="p-6"> <div className="p-6">
<PageMeta title="Usage" description="Monitor your plan limits and usage statistics" /> <PageMeta title="Usage" description="Monitor your plan limits and usage statistics" />
<div className="mb-6"> <div className="mb-6">
<h1 className="text-2xl font-bold text-gray-900 dark:text-white">Acoount Limits Usage 9</h1> <h1 className="text-2xl font-bold text-gray-900 dark:text-white">Acoount Limits Usage 12</h1>
<p className="text-gray-600 dark:text-gray-400 mt-1">Monitor your plan limits and usage statistics</p> <p className="text-gray-600 dark:text-gray-400 mt-1">Monitor your plan limits and usage statistics</p>
</div> </div>

View File

@@ -3,13 +3,75 @@ import react from "@vitejs/plugin-react";
import svgr from "vite-plugin-svgr"; import svgr from "vite-plugin-svgr";
import { resolve } from "path"; import { resolve } from "path";
// Custom plugin to bypass Vite 6.1.0 host check bug
// The host check middleware runs early, so we intercept and remove it
const bypassHostCheck = () => {
return {
name: 'bypass-host-check',
configureServer(server) {
// Remove host check middleware by intercepting the middleware stack
const originalUse = server.middlewares.use.bind(server.middlewares);
server.middlewares.use = function(path, ...handlers) {
// Filter out any handler that checks for allowedHosts
const filteredHandlers = handlers.filter(handler => {
if (typeof handler === 'function') {
const handlerStr = handler.toString();
// Skip handlers that check for "allowedHosts" or "not allowed"
if (handlerStr.includes('allowedHosts') || handlerStr.includes('not allowed')) {
return false;
}
}
return true;
});
return originalUse(path, ...filteredHandlers);
};
// Also remove from existing stack
if (Array.isArray(server.middlewares.stack)) {
server.middlewares.stack = server.middlewares.stack.filter(middleware => {
if (middleware && middleware.handle) {
const handlerStr = middleware.handle.toString();
return !handlerStr.includes('allowedHosts') && !handlerStr.includes('not allowed');
}
return true;
});
}
}
};
};
// Plugin to serve marketing.html at root for marketing dev server
const serveMarketingAtRoot = () => {
return {
name: 'serve-marketing-at-root',
configureServer(server) {
server.middlewares.use((req, res, next) => {
// If on port 5174 and requesting root, serve marketing.html
if (server.config.server.port === 5174 && req.url === '/') {
req.url = '/marketing.html';
}
next();
});
}
};
};
// https://vite.dev/config/ // https://vite.dev/config/
export default defineConfig(({ mode }) => { export default defineConfig(({ mode, command }) => {
const isDev = mode === "development"; // Always enable dev server config when running dev command (serve)
const isDev = mode === "development" || command === "serve";
const isMarketingBuild = mode === "marketing"; const isMarketingBuild = mode === "marketing";
// Check if we're running marketing dev server (port 5174)
const isMarketingDev = process.env.PORT === "5174" || process.argv.includes("--port") && process.argv[process.argv.indexOf("--port") + 1] === "5174";
return { return {
// Set root HTML file for marketing dev server
root: __dirname,
publicDir: "public",
plugins: [ plugins: [
bypassHostCheck(), // Workaround for Vite 6.1.0 host check bug
...(process.env.PORT === "5174" || process.argv.includes("--port") && process.argv[process.argv.indexOf("--port") + 1] === "5174" ? [serveMarketingAtRoot()] : []),
react(), react(),
svgr({ svgr({
svgrOptions: { svgrOptions: {
@@ -79,37 +141,29 @@ export default defineConfig(({ mode }) => {
// Report compressed sizes // Report compressed sizes
reportCompressedSize: true, reportCompressedSize: true,
}, },
// Only configure server and HMR in development mode // Server configuration - ALWAYS apply (not conditional)
...(isDev && { // This ensures server config is loaded even with --force flag
server: { server: {
host: "0.0.0.0", // Allow external connections (for Docker) host: "0.0.0.0", // Allow external connections (for Docker)
port: isMarketingBuild ? 5174 : 5173, // Different port for marketing dev port: isMarketingBuild ? 5174 : 5173, // Different port for marketing dev
strictPort: false, // Allow port fallback if port is busy strictPort: false, // Allow port fallback if port is busy
// Disable host check for development (behind reverse proxy) // Vite 6.1.0: Host check is skipped if allowedHosts === true
// Vite 6.1.0: Must explicitly list all hosts // Set to true to allow all hosts (safe behind Caddy reverse proxy)
allowedHosts: [ // Note: We patched Vite source to always skip host check, but keeping this for safety
"igny8.com", allowedHosts: true,
"www.igny8.com", watch: {
"app.igny8.com", usePolling: true, // Needed for file watching in Docker
"api.igny8.com",
"localhost",
"127.0.0.1",
"0.0.0.0"
],
watch: {
usePolling: true, // Needed for file watching in Docker
},
hmr: {
// Behind reverse proxy - use same origin strategy
// Client connects via public domain on default HTTPS port (443)
// Caddy automatically proxies WebSocket upgrades from 443 to dev port
protocol: "wss",
// Don't specify host/port - Vite will use same origin as page
// This ensures client connects to wss://domain.com (port 443 implicit)
},
// Increase timeout for slow connections and dependency pre-bundling
timeout: 120000, // 120 seconds (2 minutes) to match Caddy timeout
}, },
}), hmr: {
// Behind reverse proxy - use same origin strategy
// Client connects via public domain on default HTTPS port (443)
// Caddy automatically proxies WebSocket upgrades from 443 to dev port
protocol: "wss",
// Don't specify host/port - Vite will use same origin as page
// This ensures client connects to wss://domain.com (port 443 implicit)
},
// Increase timeout for slow connections and dependency pre-bundling
timeout: 120000, // 120 seconds (2 minutes) to match Caddy timeout
},
}; };
}); });