From a8a99f4f531ce70d698b1ad1322afe77b8db1d4d Mon Sep 17 00:00:00 2001 From: MayaTheShy Date: Mon, 16 Feb 2026 00:24:38 -0500 Subject: [PATCH] fix: Update Dockerfile to use serve for production and enhance Vite configuration with CORS support --- client/Dockerfile | 11 +++++++---- client/vite.config.js | 10 ++++++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/client/Dockerfile b/client/Dockerfile index 684170f..d100e26 100644 --- a/client/Dockerfile +++ b/client/Dockerfile @@ -1,4 +1,4 @@ -# Production build with Vite preview server +# Production build with simple HTTP server FROM node:18-alpine WORKDIR /app @@ -15,8 +15,11 @@ COPY . . # Build the app RUN npm run build -# Expose port for Vite preview server +# Install serve globally for serving static files +RUN npm install -g serve + +# Expose port EXPOSE 3000 -# Serve built files with Vite preview (allow all hosts) -CMD ["npm", "run", "preview", "--", "--host", "0.0.0.0", "--port", "3000", "--strictPort"] +# Serve built files with serve (no host restrictions) +CMD ["serve", "-s", "dist", "-l", "3000"] diff --git a/client/vite.config.js b/client/vite.config.js index c67f4b7..9c45909 100644 --- a/client/vite.config.js +++ b/client/vite.config.js @@ -5,12 +5,18 @@ export default defineConfig({ plugins: [react()], server: { port: 3000, - host: '0.0.0.0' + host: '0.0.0.0', + hmr: { + clientPort: 3000 + } }, preview: { port: 3000, host: '0.0.0.0', strictPort: true, - allowedHosts: 'all' + cors: true, + headers: { + 'Access-Control-Allow-Origin': '*' + } } })