don't ignore .well-known (or any dot files)

This commit is contained in:
AJ ONeal 2015-12-11 05:54:30 +00:00
parent 3c2568b66c
commit 841d6b3948
1 changed files with 24 additions and 2 deletions

View File

@ -89,13 +89,18 @@ function loadPages(pkgConf, route, req, res, next) {
if (!route._promise_app) { if (!route._promise_app) {
route._promise_app = new PromiseA(function (resolve, reject) { route._promise_app = new PromiseA(function (resolve, reject) {
fs.exists(pkgpath, function (exists) { fs.exists(pkgpath, function (exists) {
var staticServer;
if (!exists) { if (!exists) {
reject(new Error("package is registered but does not exist")); reject(new Error("package is registered but does not exist"));
return; return;
} }
//console.log('[static mount]', pkgpath); //console.log('[static mount]', pkgpath);
resolve(require('serve-static')(pkgpath)); // https://github.com/expressjs/serve-static/issues/54
// https://example.com/.well-known/acme-challenge/xxxxxxxxxxxxxxx
staticServer = require('serve-static')(pkgpath, { dotfiles: 'allow' });
resolve(staticServer);
}); });
}); });
} }
@ -374,10 +379,27 @@ function mapToApp(opts, req, res, next) {
return; return;
} }
// TODO .well-known can be an API (webfinger, letsencrypt, oauth3)
// or static (...???)
if (!router._re_api.test(req.url)) { if (!router._re_api.test(req.url)) {
//console.log('[static router]'); //console.log('[static router]');
//console.log(router._re_api, req.url); //console.log(router._re_api, req.url);
layerItUp(pkgConf, router, req, res, next); layerItUp(pkgConf, router, req, res, function (err) {
if (err) {
next(err);
return;
}
if (/\/\.well-known([\/?]|$)/.test(req.url)) {
console.log('[TODO] handle .well-known as API');
// rewrite api as /api/org.ietf/.well-known ?
// pass through simply as /.well-known ?
// runApi(opts, router, req, res, next)
}
next();
});
return; return;
} }