我正在按照本教程jwt authentication在hapijs v17.2.
我按照教程做了一切,但以下错误让我发疯,甚至调试也没有做出任何改变。
错误
Debug: internal, implementation, error
TypeError: cb is not a function
at Object.secretProvider [as key] (C:\Users\user\WebstormProjects\hapi-blog\node_modules\jwks-rsa\lib\integrations\hapi.js:30:14)
at Object.authenticate (C:\Users\user\WebstormProjects\hapi-blog\node_modules\hapi-auth-jwt2\lib\index.js:123:87)
at module.exports.internals.Manager.execute (C:\Users\user\WebstormProjects\hapi-blog\node_modules\hapi\lib\toolkit.js:35:106)
at module.exports.internals.Auth._authenticate (C:\Users\user\WebstormProjects\hapi-blog\node_modules\hapi\lib\auth.js:242:58)
at authenticate (C:\Users\user\WebstormProjects\hapi-blog\node_modules\hapi\lib\auth.js:217:21)
at module.exports.internals.Request._lifecycle (C:\Users\user\WebstormProjects\hapi-blog\node_modules\hapi\lib\request.js:261:62)
at <anonymous>
Run Code Online (Sandbox Code Playgroud)
应用程序.js
const hapi = require('hapi');
const mongoose = require('./db');
const hapi_auth_jwt = require('hapi-auth-jwt2');
const jwksa_rsa = require('jwks-rsa');
const dog_controller = require('./controllers/dog');
const server = new hapi.Server({
host: 'localhost',
port: 4200
});
const validate_user = (decoded, request, callback) …Run Code Online (Sandbox Code Playgroud) 部署到IIS后,我发现我的路由均不起作用,因此我进行了研究,然后发现了这个问题,其中说您必须向进行重写web.config,而我已经做了,路由现在可以正常工作。
这是我的一些在开发模式下有效但在生产中有效的路线:
const appRoutes: Routes = [
{ path: '', component: HomeComponent },
{ path: 'manage', component: ManageComponent },
{ path: 'manage/products', component: ProductComponent },
{ path: 'manage/products/:action/:id', component: ProductComponent },
{ path: 'manage/companies', component: CompanyComponent },
];
Run Code Online (Sandbox Code Playgroud)
我所做的web.config:
<system.webServer>
<rewrite>
<rules>
<rule name="Angular Routes" stopProcessing="true">
<match url=".*"/>
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
<add input="{REQUEST_URI}" pattern="^/(api)" negate="true"/>
</conditions>
<action type="Rewrite" url="/"/>
</rule>
</rules>
</rewrite>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)
那么实际的问题是什么呢?当我刷新/重定向页面时会出现问题。经过一个小时的研究,发现我编写的规则web.config总是返回index.html …