Running Express JS Application via Plesk in Mocha Host Windows Hosting
Nowadays, to run an application balancing best practices and ease of use need tons number of different technology. That means documentations are scattered too.
I have an Express JS application that I need to be hosted and since I have active plan under Mocha Host, I decided to host it there. My hosting server is Windows and it supports Node.JS. Looking into the settings, it is as simple as enabling Node.JS. However, after managing to deploy the application, it doesn't run as expected as it returns 404 for known url.
When I finally managed to solve the running issue, there are many steps that I need to configure to get my application working.
Step 1
I'm using Express JS version 4 generated via express-generator, so the starting script is not app.js, but /bin/www. So following the instruction in the article below:
https://www.plesk.com/blog/product-technology/node-js-plesk-onyx/
I created a new entry file called service.js. The content is simple as follow:
const app = require('./app');
const http = require('http');
http.createServer(app).listen(process.env.PORT);
Step 2
In Plesk under Websites & Domains > YOUR_WEBSITE > Node.js > Application StartUp File, change it from app.js to server.js.
- https://www.a2hosting.co.id/kb/developer-corner/making-a-simple-node.js-application-in-plesk-for-windows
- https://support.plesk.com/hc/en-us/articles/360010589619-Node-js-application-subpath-shows-error-404-after-being-deployed-in-Plesk
- https://talk.plesk.com/threads/use-nodejs-and-problem-with-express-routing.343510/
Comments
Post a Comment