【发布时间】:2012-03-29 11:40:34
【问题描述】:
如果我不在我的 CouchDB 应用程序中使用重写,我的静态文件链接会中断:
GET http://127.0.0.1:5984/mythshare-dev/_design/mythshare/_rewrite/static/js/jquery-1.7.1.min.js 404 (Object Not Found)
GET http://127.0.0.1:5984/mythshare-dev/_design/mythshare/_rewrite/static/js/json2.js 404 (Object Not Found)
GET http://127.0.0.1:5984/mythshare-dev/_design/mythshare/_rewrite/static/style/example.css 404 (Object Not Found)
modules.js:4264Uncaught ReferenceError: $ is not defined
所以我添加了这个重写来修复损坏的链接:
{from: '/static/*', to: 'static/*'}
我损坏的链接已修复,但处理程序无法正常工作。 modules.js 的 handle 函数不匹配...
exports.handle = function (method, url, data) {
if (exports.unknown_target) {
window.location = exports.getBaseURL() + url;
return;
}
// match resolves to FALSE
var match = exports.matchURL(method, url);
...
这导致了:
...
else {
// this log is written over and over in the console
console.log(method + ' ' + url + ' -> [404]');
window.location = exports.getBaseURL() + url;
return;
}
页面现在不断刷新,陷入无限循环。
如何将重写写入静态目录,以便正确解析并匹配?
【问题讨论】:
-
似乎在 base.html 文件模板中包含“modules.js”文件导致了这种情况。删除它后,页面可以工作。不过,我会暂时搁置一下,希望有人知道错误的根本原因并提供帮助。
标签: redirect url-rewriting couchdb infinite-loop couchapp