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
|
FROM node:18-alpine
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@@ -15,8 +15,11 @@ COPY . .
|
|||||||
# Build the app
|
# Build the app
|
||||||
RUN npm run build
|
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
|
EXPOSE 3000
|
||||||
|
|
||||||
# Serve built files with Vite preview (allow all hosts)
|
# Serve built files with serve (no host restrictions)
|
||||||
CMD ["npm", "run", "preview", "--", "--host", "0.0.0.0", "--port", "3000", "--strictPort"]
|
CMD ["serve", "-s", "dist", "-l", "3000"]
|
||||||
|
|||||||
@@ -5,12 +5,18 @@ export default defineConfig({
|
|||||||
plugins: [react()],
|
plugins: [react()],
|
||||||
server: {
|
server: {
|
||||||
port: 3000,
|
port: 3000,
|
||||||
host: '0.0.0.0'
|
host: '0.0.0.0',
|
||||||
|
hmr: {
|
||||||
|
clientPort: 3000
|
||||||
|
}
|
||||||
},
|
},
|
||||||
preview: {
|
preview: {
|
||||||
port: 3000,
|
port: 3000,
|
||||||
host: '0.0.0.0',
|
host: '0.0.0.0',
|
||||||
strictPort: true,
|
strictPort: true,
|
||||||
allowedHosts: 'all'
|
cors: true,
|
||||||
|
headers: {
|
||||||
|
'Access-Control-Allow-Origin': '*'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user