I have read up solution from different stack overflow but non solves the problem
This end point works fine on local host and heroku some month ago but now it works fine only on local host I get this error after I try to access the end point
server.js file
'use strict';
require("dotenv").config();
require('./MongoDB/DB')
const http = require('http');
const express = require('express');
const cors = require("cors");
const mongoSanitize = require('express-mongo-sanitize');
let cookieParser = require('cookie-parser');
const app = express();
const server = http.createServer(app)
const port=process.env.PORT||5000;
const passportContol=require("./Passport/index")
app.use(cors())
app.use(cookieParser())
app.use(express.json({ limit: "1kb" }));
app.use(express.urlencoded({ extended: true,limit: "1kb"}));
app.use(
mongoSanitize({
replaceWith: '_',
}),
);
app.use(passportContol.initialize());
app.set('trust proxy', 1);
const router1=require('./Router/Account')
const router2=require('./Router/Post')
const router3=require('./Router/Request')
app.use("/",router1);
app.use("/",router2);
app.use("/",router3);
server.listen(port ,()=>console.log(`server started.... ${port}`))
package.json
{
"name": "api-campus-bet",
"version": "1.0.0",
"description": "campus-bet api for soccer betting",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js",
"dev": "nodemon server"
},
"author": "Ogbonna Chinaza",
"license": "ISC",
"dependencies": {
"axios": "^0.26.1",
"bcrypt": "^5.0.1",
"cookie": "^0.4.2",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"csurf": "^1.11.0",
"dotenv": "^16.0.0",
"express": "^4.17.3",
"express-mongo-sanitize": "^2.2.0",
"express-rate-limit": "^6.3.0",
"ioredis": "^5.0.3",
"jsonwebtoken": "^8.5.1",
"mongoose": "^6.2.9",
"passport": "^0.5.2",
"passport-local": "^1.0.0"
},
"engines": {
"node": "16.13.1"
}
}
Procfile
web: node server.js
WHAT I HAVE DONE
- I have reinstall the nodemodule i did this including package-lock.json
- I have cleared heroku cache (git commit --allow-empty -m "Purge cache" $ git push heroku master)
- I deleted the whole project on heroku and push a new one with no error message
with some other things
please I need help what have I done wrong