【问题标题】:"Cannot GET /test_app" error on A2HostingA2Hosting 上的“无法获取 /test_app”错误
【发布时间】:2020-07-28 18:40:00
【问题描述】:

在 A2 Hosting 文档中,他们提供了有关如何创建 NodeJS 应用程序并通过其 cPanel 界面运行它的示例。

我已经设置了一个简单的 nodejs hello world 测试应用程序,但是我得到了一个“Cannot GET /test_app”错误。

设置:

当我在浏览器中运行应用程序 (https://api.domain.com/test_app) 时,我收到“Cannot GET /test_app”错误。

在日志中我可以看到应用程序正在运行: 应用程序 30562 输出:示例应用程序在 5575 侦听

关于我在 NodeJS 设置中缺少什么的任何建议?

【问题讨论】:

    标签: node.js hosting


    【解决方案1】:

    在 cPanel 上运行 NodeJS 部署的应用程序的问题。

    A2 Hosting 使用 Phusion Passenger 作为其部署代理,它不使用根路径作为“/”,而是使用“/yourAppURL”来转发请求。所以在你的 NodeJS 代码中,你必须在使用 Express 时将指定的 AppURLPath 添加到路由中......

    例如

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

    【讨论】:

      猜你喜欢
      • 2021-01-08
      • 1970-01-01
      • 2018-12-09
      • 1970-01-01
      • 2023-03-25
      • 1970-01-01
      • 2014-02-14
      • 1970-01-01
      相关资源
      最近更新 更多