OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Node.js (Express) Restful API App in Cpanel not working(APIs)? getting 503 Service Unavailable

  • Thread starter Thread starter Thanushkanth Shan
  • Start date Start date
T

Thanushkanth Shan

Guest
In this case I have mention auth API, other APIs also not working getting same results

In localhost it's working (server.use('/auth', routeAuth);)

In server once I created Node app in Cpanel (server.use('/server/auth', routeAuth);) which is not working

In server code block below server.js

Code:
const express = require('express');
const server = express();
const cors = require('cors');

const routeAuth = require('./auth/auth');
const routeRegister = require('./auth/register');

const routeArticle = require('./api/article/article');

const PORT = process.env.PORT || 4300;

server.use(express.json());
server.use(express.urlencoded({ extended: false}));
server.use(cors());

server.use('/server/auth', routeAuth);
server.use('/server/', routeRegister);

server.use('/server/api', routeArticle);

server.listen(PORT, () => console.log(`Server started on port: ${PORT}`));

localhost Postman test working enter image description here

After deploy to server and the result not working enter image description here

<p>In this case I have mention auth API, other APIs also not working getting same results</p>
<p>In localhost it's working (<code>server.use('/auth', routeAuth);</code>)</p>
<p>In server once I created Node app in Cpanel (<code>server.use('/server/auth', routeAuth);</code>) which is not working</p>
<p>In server code block below server.js</p>
<pre><code>const express = require('express');
const server = express();
const cors = require('cors');

const routeAuth = require('./auth/auth');
const routeRegister = require('./auth/register');

const routeArticle = require('./api/article/article');

const PORT = process.env.PORT || 4300;

server.use(express.json());
server.use(express.urlencoded({ extended: false}));
server.use(cors());

server.use('/server/auth', routeAuth);
server.use('/server/', routeRegister);

server.use('/server/api', routeArticle);

server.listen(PORT, () => console.log(`Server started on port: ${PORT}`));
</code></pre>
<p>localhost Postman test working
<a href="https://i.sstatic.net/2lHQu.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/2lHQu.png" alt="enter image description here" /></a></p>
<p>After deploy to server and the result not working
<a href="https://i.sstatic.net/E8sU6.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/E8sU6.png" alt="enter image description here" /></a></p>
 
Top