Cześć, chcę postawić mój serwer na Heroku i frontend na netlify, wrzuciłem backend na Heroku ale jak chce wejść w ta aplikacje to wyświetla się : "Not found" i w konsoli "Failed to load resource: the server responded with a status of 404 (Not Found)".
Mój index.js:
const express = require("express");
const cors = require("cors");
const mongoose = require("mongoose");
const bodyParser = require("body-parser");
const path = require("path");
const favicon = require("express-favicon");
// routes
const usersRouter = require("./routes/users-routes");
const restaurantRouter = require("./routes/restaurant-routes");
const dotenv = require("dotenv");
dotenv.config();
const app = express();
const port = process.env.PORT || 8000;
app.use(express.json());
app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static(path.join(__dirname, "../build/static")));
app.get("*", (req, res) => {
res.sendFile(path.join(__dirname, "../build/index.html"));
});
app.use(favicon(__dirname + "../public/favicon.ico"));
const uri = process.env.ATLAS_URI;
mongoose.connect(uri, { useNewUrlParser: true });
const connection = mongoose.connection;
connection.once("open", () => {
console.log("MongoDB databse connection estabilished succesfully");
});
app.listen(port, () => {
console.log(`Sever is running on port ${port}`);
});
app.use("/users", usersRouter);
app.use("/restaurants", restaurantRouter);
i tutaj mój package.json
{
"name": "backend",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon server"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"bcryptjs": "^2.4.3",
"body-parser": "^1.19.2",
"cors": "^2.8.5",
"dotenv": "^16.0.0",
"express": "^4.17.3",
"express-favicon": "^2.0.1",
"mongoose": "^6.2.9",
"nodemon": "^2.0.15",
"ts-node": "^10.7.0"
},
"proxy": "http://localhost:8000",
"engines": {
"node": "14.17.0"
}
}
Gdyby ktoś wiedział co mogę z tym zrobić to z góry dziękuję za pomoc.