【问题标题】:404 angularjs http post to a php file404 angularjs http 发布到 php 文件
【发布时间】:2018-01-31 08:14:59
【问题描述】:

我在 heroku 上托管了一个小型网络应用程序。我的问题是当我尝试从 angularjs 执行 php 文件时,控制台日志说我找不到它。在我的本地主机上完美运行! 这是代码。

从控制器(app.js):

$http({
            method: 'POST',
            url: 'generarPDF.php',
            data: misProductos,
        }).
        then(function(response){
            alert(response.data);
        })

我的 php 只是接收数据并通过邮件发送。控制器文件和 php 文件在同一目录中。 节点服务器:

var app = express();
app.use(express.static(path.join(__dirname)));

app.get('/', function(req, res){
    res.sendFile(path.join(__dirname + '/admin_3/index.html'));
});
app.get('/page_general_portfolio_3.html', function(req, res){
    res.sendFile(path.join(__dirname + '/admin_3/page_general_portfolio_3.html'));
});
app.get('/page_general_about.html', function(req, res){
    res.sendFile(path.join(__dirname + '/admin_3/page_general_about.html'));
});
app.get('/form_controls_md.html', function(req, res){
    res.sendFile(path.join(__dirname + '/admin_3/form_controls_md.html'));
});
app.get('/ecommerce_products_edit.html', function(req, res){
    res.sendFile(path.join(__dirname + '/admin_3/ecommerce_products_edit.html'));
});

这是heroku日志:

2018-01-31T00:00:41.789571+00:00 heroku[web.1]:停止所有进程 使用 SIGTERM 2018-01-31T00:00:41.867855+00:00 heroku[web.1]:进程 退出状态为 143 2018-01-31T00:00:51.631278+00:00 heroku[web.1]: 使用命令npm start启动进程

提前致谢!

【问题讨论】:

  • the console log says me that can't found it api can' found or file can't found?

标签: php angularjs node.js heroku


【解决方案1】:

你使用什么端口?你需要使用

app.listen(process.env.PORT | 1234, ()=> console.log());

process.env.PORT别忘了这个

【讨论】:

  • 是的,我正在监听 const port = process.env.PORT || 3000;
猜你喜欢
  • 2016-12-15
  • 2013-03-07
  • 1970-01-01
  • 2018-04-19
  • 2019-11-11
  • 2013-04-12
  • 1970-01-01
  • 2015-04-24
  • 1970-01-01
相关资源
最近更新 更多