Heroku+jekyll部署将index.html附加到AJAX post中


Heroku+jekyll deployment appends index.html to AJAX post

我有一个ajax调用正在发布到/php/rsvp.php。由于某种原因,当这个调用通过web服务器时,index.html被附加到路径上。该应用程序使用puma托管在heroku上。下面是带有堆栈跟踪的日志:

2015-10-12T01:48:57.898961+00:00 heroku[router]: at=info method=POST path="/php/rsvp.php" host= request_id= fwd="" dyno=web.1 connect=1ms service=9ms status=500 bytes=168
2015-10-12T01:48:57.901579+00:00 app[web.1]: 2015-10-12 01:48:57 +0000: Rack app error: #<Errno::ENOTDIR: Not a directory @ rb_sysopen - /app/_site/php/rsvp.php/index.html>
2015-10-12T01:48:57.901635+00:00 app[web.1]: /app/vendor/bundle/ruby/2.1.0/gems/rack-jekyll-0.4.1/lib/rack/jekyll/helpers.rb:14:in `initialize'
2015-10-12T01:48:57.901639+00:00 app[web.1]: /app/vendor/bundle/ruby/2.1.0/gems/rack-jekyll-0.4.1/lib/rack/jekyll/helpers.rb:14:in `open'
2015-10-12T01:48:57.901640+00:00 app[web.1]: /app/vendor/bundle/ruby/2.1.0/gems/rack-jekyll-0.4.1/lib/rack/jekyll/helpers.rb:14:in `file_info'
2015-10-12T01:48:57.901642+00:00 app[web.1]: /app/vendor/bundle/ruby/2.1.0/gems/rack-jekyll-0.4.1/lib/rack/jekyll.rb:75:in `call'
2015-10-12T01:48:57.901644+00:00 app[web.1]: /app/vendor/bundle/ruby/2.1.0/gems/puma-2.9.1/lib/puma/configuration.rb:71:in `call'
2015-10-12T01:48:57.901645+00:00 app[web.1]: /app/vendor/bundle/ruby/2.1.0/gems/puma-2.9.1/lib/puma/server.rb:490:in `handle_request'
2015-10-12T01:48:57.901647+00:00 app[web.1]: /app/vendor/bundle/ruby/2.1.0/gems/puma-2.9.1/lib/puma/server.rb:361:in `process_client'
2015-10-12T01:48:57.901649+00:00 app[web.1]: /app/vendor/bundle/ruby/2.1.0/gems/puma-2.9.1/lib/puma/server.rb:254:in `block in run'
2015-10-12T01:48:57.901652+00:00 app[web.1]: /app/vendor/bundle/ruby/2.1.0/gems/puma-2.9.1/lib/puma/thread_pool.rb:92:in `call'
2015-10-12T01:48:57.901692+00:00 app[web.1]: /app/vendor/bundle/ruby/2.1.0/gems/puma-2.9.1/lib/puma/thread_pool.rb:92:in `block in spawn_thread'

我一直在查看puma和rack-jekyll函数,以找到追加发生的位置,但没有一个条件是有意义的。我还没有找到任何关于这个问题的其他帖子,这让我觉得我正在监督一些简单的事情。正在进行的ajax调用非常简单:

req = $.post( '/rsvp.php', $form.serialize(), function(data, status){});

是否缺少一些配置来防止这种情况?我的Gemfile, _config。Yml, config.ru等与此处相同

所以我们也有这个问题,只是刚刚发现它。问题是rack-jekyll gem有一个错误,它假设没有mime类型的文件是目录。参见问题:https://github.com/adaoraul/rack-jekyll/issues/38

这个错误修复已经完成了,看起来它会在0.4.3发布,但在此期间,我们通过在config.ru文件中添加以下行来解决这个问题,它为.php扩展名添加了mime类型: Rack::Mime::MIME_TYPES.merge!({".php" => "application/octet-stream"})