fix: serve frontend static files and build in docker
This commit is contained in:
@@ -7,6 +7,9 @@ RUN npm install
|
||||
|
||||
COPY . .
|
||||
|
||||
# Build the frontend
|
||||
RUN npm run build
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["npm", "run", "start"]
|
||||
|
||||
@@ -40,6 +40,14 @@ if (!fs.existsSync(uploadsPath)) {
|
||||
|
||||
app.use('/uploads', express.static(uploadsPath));
|
||||
|
||||
// Serve frontend static files
|
||||
const distPath = path.join(process.cwd(), 'dist');
|
||||
app.use(express.static(distPath));
|
||||
|
||||
app.get('*', (req, res) => {
|
||||
res.sendFile(path.join(distPath, 'index.html'));
|
||||
});
|
||||
|
||||
// Routes
|
||||
app.use('/api/users', userRoutes);
|
||||
app.use('/api/projects', projectRoutes);
|
||||
|
||||
Reference in New Issue
Block a user