23 lines
677 B
JavaScript
23 lines
677 B
JavaScript
const express = require('express');
|
|
const path = require('path');
|
|
const app = express();
|
|
|
|
// Serve static files from the React app
|
|
app.use(express.static(path.join(__dirname, '../client/makerspace/dist')));
|
|
|
|
// Handle GET requests to /api route
|
|
app.get("/api", (req, res) => {
|
|
res.json({ message: "Hello from server!" });
|
|
});
|
|
|
|
// All other GET requests will be handled by React app
|
|
app.get('*', (req, res) => {
|
|
res.sendFile(path.resolve(__dirname, '../client/makerspace/dist', 'index.html'));
|
|
});
|
|
|
|
// Start the server
|
|
const PORT = process.env.PORT || 9111;
|
|
app.listen(PORT, () => {
|
|
console.log(`App listening on port ${PORT}`);
|
|
console.log('Press Ctrl+C to quit.');
|
|
}); |