How can I fix this CouchDB rewrite handler's infinite loop?
-
27-05-2021 - |
题
If I don't use a rewrite in my CouchDB app, my static file links break:
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
So I added this rewrite to fix the broken links:
{from: '/static/*', to: 'static/*'}
My broken links are fixed, but the handler doesn't work properly. modules.js
's handle function doesn't match...
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);
...
Which leads to this:
...
else {
// this log is written over and over in the console
console.log(method + ' ' + url + ' -> [404]');
window.location = exports.getBaseURL() + url;
return;
}
The page now constantly refreshes, caught in an infinite loop.
How can I write the rewrite to the static directory so it resolves properly and matches?
解决方案
Remove the script tag for modules.js
in the base.html
template.
不隶属于 StackOverflow