Servicestack 中的 FallbackRoute 问题

Problem with FallbackRoute in Servicestack

我正在使用 Servicestack 反应模板,我注意到在 chrome 中我在控制台中收到错误,表明 manifest.json 不可访问。经过一番摸索,我认为问题出在回退路线上。

最初模板包含如下回退路线:

[FallbackRoute("/{PathInfo*}", Matches="AcceptsHtml")]

这是有道理的,因为 manifest.json 不是 html,所以我明白为什么我会收到 403 错误。

但是,将路由更改为:

[FallbackRoute("/{PathInfo*}", Matches = @"PathInfo =~ \/(index\.html|manifest\.json|favicon\.ico)$")]

根据我的理解应该匹配 index.html 或 manifest.json 或 favicon.ico,仍然不起作用。 Index.html 和 favicon.ico 工作正常,但是我在请求 manifest.json 时收到 'forbidden' 错误,这很奇怪,因为该文件与另一个文件位于同一文件夹中,具有相同的权限2 个文件。

我错过了什么?

您想要允许的任何静态文件需要在 Config.AllowFileExtensions 中指定,以允许访问 .json 静态文件,在您的 HostConfig 中添加扩展名,例如:

SetConfig(new HostConfig {
    AllowFileExtensions = { "json" }
});