我试图在成功投放的aws linux实例上运行express-stormpath。我已经加倍和三倍检查了我的密钥和应用程序hrefs并确保它们已连接到应用程序。我已经去了一个新的虚拟机,并使用最简单的服务来确保在我成功提供sailsjs应用程序的虚拟机中没有出现问题。
var express = require('express');
var stormpath = require('express-stormpath');
var app = express();
var stormpathInit = function(req,res,next) {
stormpath.init(app, {
apiKey: {
id:'##########',
secret: '############',
},
secretKey: 'theLongRoadToNowhere',
application: 'https://api.stormpath.com/v1/applications/###',
website: true,
api: true
});
next();
};
app.use(stormpathInit);
app.get('/', function (req, res) {
res.send('<a href="/login">Login</a>');
});
/* and this failed as well with the same output only on server startup
app.use(stormpath.init(app, {
apiKey: {
id:'4SL89BZ47ALZX6T9W7S4NPUXS',
secret: 's0dA33RPTAqcDAcdbwj6q9i0qDDEr0XyHhsBmjF34SY',
},
secretKey: 'theLongRoadToFreedomWillPayDividends',
application: 'https://api.stormpath.com/v1/applications/1wShCspJ1NFnT1N1UM1laJ',
website: true,
api: true
}));
*/
app.listen(1337);
///////////////////////
The error output:
req.uri = undefined
/var/www/stormpath/node_modules/express-stormpath/node_modules/stormpath/lib/ds/RequestExecutor.js:70
throw new Error('request.uri field is required.');
^
Error: request.uri field is required.
at RequestExecutor.executeRequest [as execute] (/var/www/stormpath/node_modules/express-stormpath/node_modules/stormpath/lib/ds/RequestExecutor.js:70:13)
at doRequest (/var/www/stormpath/node_modules/express-stormpath/node_modules/stormpath/lib/ds/DataStore.js:277:27)
at onCacheResult (/var/www/stormpath/node_modules/express-stormpath/node_modules/stormpath/lib/ds/DataStore.js:301:5)
at Array.<anonymous> (/var/www/stormpath/node_modules/express-stormpath/node_modules/stormpath/lib/cache/Cache.js:54:14)
at DisabledCache.get.DisabledCache.set.DisabledCache.delete.DisabledCache.clear.DisabledCache.size (/var/www/stormpath/node_modules/express-stormpath/node_modules/stormpath/lib/cache/DisabledCache.js:11:62)
at Cache.get (/var/www/stormpath/node_modules/express-stormpath/node_modules/stormpath/lib/cache/Cache.js:52:14)
at CacheHandler.getCachedResource [as get] (/var/www/stormpath/node_modules/express-stormpath/node_modules/stormpath/lib/cache/CacheHandler.js:91:51)
at Object.executeRequest [as exec] (/var/www/stormpath/node_modules/express-stormpath/node_modules/stormpath/lib/ds/DataStore.js:294:22)
at DataStore.getResource (/var/www/stormpath/node_modules/express-stormpath/node_modules/stormpath/lib/ds/DataStore.js:122:16)
at Client.getResource (/var/www/stormpath/node_modules/express-stormpath/node_modules/stormpath/lib/Client.js:313:38)
感谢任何指导......
答案 0 :(得分:3)
不幸的是,光子的答案对我不起作用,但在与Stormpath支持沟通后(这非常有帮助)以下解决了我的问题:
通过在shell中运行它来设置环境变量STORMPATH_APPLICATION_HREF
:
export STORMPATH_APPLICATION_HREF=<YourAppsHREF>
希望这也适用于其他人。
问题似乎是stormpath文档中的一个小错字。他们目前指示您设置名为STORMPATH_CLIENT_APPLICATION_HREF
的环境变量。这是不正确的,它应该是STORMPATH_APPLICATION_HREF
,如上所示。
答案 1 :(得分:2)
我遇到了同样的问题,在查看了当前的default options for the Stormpath middleware后,更改以下行解决了我的问题。
<强>之前强>
application: 'https://api.stormpath.com/v1/applications/1wShCspJ1NFnT1N1UM1laJ'
<强>后强>
application: {
href: 'https://api.stormpath.com/v1/applications/1wShCspJ1NFnT1N1UM1laJ'
}