fix: Update Dockerfile to use serve for production and enhance Vite configuration with CORS support
This commit is contained in:
@@ -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"]
|
||||
|
||||
@@ -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': '*'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user