Initial commit
This commit is contained in:
20
server/index.js
Normal file
20
server/index.js
Normal file
@ -0,0 +1,20 @@
|
||||
const express = require("express");
|
||||
const path = require("path");
|
||||
|
||||
const PORT = process.env.PORT || 3001;
|
||||
|
||||
const app = express();
|
||||
|
||||
app.use(express.static(path.resolve(__dirname, '../client/build')));
|
||||
|
||||
app.get("/api", (req, res) => {
|
||||
res.json({ message: "Hello from server!" });
|
||||
});
|
||||
|
||||
app.get('*', (req, res) => {
|
||||
res.sendFile(path.resolve(__dirname, '../client/build', 'index.html'));
|
||||
});
|
||||
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Server listening on ${PORT}`);
|
||||
});
|
Reference in New Issue
Block a user