I have a problem when I deploy my NodeJS API on CPANEL shared hosting. My application is working very well on localhost but when I deploy it, the home route is the only one working, all remaining routes are not working (500 Internal error). I use Express.
Can somebody Help me please ?
Thank you !
JavaScript:
const express = require('express');
const cors = require('cors');
const app = express();
require('dotenv').config();
// Import Routes
const productsRoute = require('./routes/products');
// Middleware
const corsOpts = {
origin: '*',
methods: ['GET', 'POST', 'PUT', 'DELETE'],
allowedHeaders: ['Content-Type'],
};
app.use(cors(corsOpts));
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.use('/products', productsRoute);
app.get('/hello', (req, res) => res.send('Hello World !'));
app.get('/', (req, res) => {
res.send("OK");
});
app.listen();
Can somebody Help me please ?
Thank you !
Last edited by a moderator: