poprawki dla dev
This commit is contained in:
@@ -34,7 +34,7 @@ class WebPanel {
|
||||
this.app.use(cors({
|
||||
origin: process.env.NODE_ENV === 'production'
|
||||
? ['https://your-domain.com']
|
||||
: ['http://localhost:3001', 'http://127.0.0.1:3001'],
|
||||
: ['http://localhost:3001', 'http://127.0.0.1:3001', 'http://localhost:3000'],
|
||||
credentials: true
|
||||
}));
|
||||
|
||||
@@ -44,8 +44,10 @@ class WebPanel {
|
||||
this.app.use(express.json({ limit: '10mb' }));
|
||||
this.app.use(express.urlencoded({ extended: true, limit: '10mb' }));
|
||||
|
||||
// Serwowanie plików statycznych (dla built React app)
|
||||
this.app.use(express.static('frontend/build'));
|
||||
// Serwowanie plików statycznych tylko w production
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
this.app.use(express.static('frontend/build'));
|
||||
}
|
||||
}
|
||||
|
||||
setupRoutes() {
|
||||
@@ -63,10 +65,12 @@ class WebPanel {
|
||||
});
|
||||
});
|
||||
|
||||
// Catch all handler dla React Router
|
||||
this.app.get('*', (req, res) => {
|
||||
res.sendFile('index.html', { root: 'frontend/build' });
|
||||
});
|
||||
// Catch all handler dla React Router - tylko w production
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
this.app.get('*', (req, res) => {
|
||||
res.sendFile('index.html', { root: 'frontend/build' });
|
||||
});
|
||||
}
|
||||
|
||||
// Error handler
|
||||
this.app.use(this.errorHandler.bind(this));
|
||||
|
||||
Reference in New Issue
Block a user