Search code examples
node.jsplesk

Failure to execute Node JS code on Plesk paanel


When I run the following code on Plesc Panel, I encounter 404 error

This code on plesk panel only work for main domin (for example ==> google.com) but for other link (for example ==> google.com/sample) I recieved 404 error page

app.use('*',function(req,res){ res.send(originalUrl); });


Solution

  • That seems a little incorrect for your use-case. Please replace your line of code with the below and it will work

    app.use(function(req, res) {
      res.send(originalUrl);
    })
    

    The above code would capture every single request on your server.