Skip to content

Commit

Permalink
Added fix for GET error on remote
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub41 committed Apr 17, 2020
1 parent 8aead5d commit b0a71c0
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions server.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
const express = require('express')
const path = require('path');
const express = require("express");
const path = require("path");

const app = express()
const port = process.env.PORT || 3000 // Heroku will need the PORT environment variable
const app = express();
const port = process.env.PORT || 3000; // Heroku will need the PORT environment variable

app.use(express.static(path.join(__dirname, 'build')));
app.use(express.static(path.join(__dirname, "build")));

app.listen(port, () => console.log(`App is live on port ${port}!`))
app.get("*", async (req, res) => {
try {
res.sendFile(path.resolve(__dirname, "build", "index.html"));
} catch (error) {
res.status(500).json(error);
}
});

app.listen(port, () => console.log(`App is live on port ${port}!`));

0 comments on commit b0a71c0

Please sign in to comment.