简体   繁体   中英

“Cannot GET /test_app” error on A2Hosting

In the A2 Hosting documentation they give a sample on how to create a NodeJS application and to run it through their cPanel interface.

I have set up a simple nodejs hello world test app, but Im getting a "Cannot GET /test_app" error.

Setup:

When I run the app in the browser ( https://api.domain.com/test_app ) I get the "Cannot GET /test_app" error.

In the log I can see that the app is running: App 30562 output: Example app listening at 5575

Any suggestions on what I'm missing with the NodeJS setup??

The problem with the application running the NodeJS deployment on cPanel.

A2 Hosting is using Phusion Passenger as it's deployment agent, and it does not use the root path as '/', but as '/yourAppURL' to forward requests to. So in your NodeJS code, you have to add the specified AppURLPath to the route when using Express...

eg

//Instead of 
app.get('/', (req, res) => res.send('Hello World!'));

//Change to
app.get('/YourSpesifiedAppURLPath/', (req, res) => res.send('Hello World!'));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM