【发布时间】:2016-09-10 22:44:24
【问题描述】:
使用以下代码在 Heroku 上创建了简单的静态站点:https://devcenter.heroku.com/articles/static-sites-ruby。
当我在浏览器中本地打开页面时,一切正常。我点击链接,然后登陆我想要的页面。
但是,当我运行 rackup (localhost:9292) 或将其推送到 heroku 时,主页会加载,然后如果我尝试转到 page2.html 之类的内容,则会加载 url,但浏览器仍会显示来自主页的数据。
我重新创建了一个简单的示例:https://peaceful-atoll-24169.herokuapp.com。我有一个带有Hello 的索引页。它应该链接到带有Yo 的页面。它转到页面,但在您单击链接时不会更改页面内容。
知道会发生什么吗?我觉得可能是因为我的 config.ru 文件?这是它的内容。
use Rack::Static,
:urls => ["/images", "/js", "/css"],
:root => "public"
run lambda { |env|
[
200,
{
'Content-Type' => 'text/html',
'Cache-Control' => 'public, max-age=86400'
},
File.open('public/index.html', File::RDONLY)
]
}
【问题讨论】:
标签: javascript html ruby-on-rails heroku static