Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

认证中间件 #3

Open
glimmerpan opened this issue Dec 9, 2024 · 1 comment
Open

认证中间件 #3

glimmerpan opened this issue Dec 9, 2024 · 1 comment

Comments

@glimmerpan
Copy link

认证中间件比对这里
this.notLoginRouters.some(
o =>
o.requestMethod === routeInfo.requestMethod &&
o.url === routeInfo.url
)
应该还要添加一个前缀的比对
o.prefix === routeInfo.prefix,
否则有不同prefix下,相同的url和请求方法会匹配到.
另外我有个疑问,我看作者大大的blog最开始是比对requestMetadata,我理解requestMetadata应该是路由表中设定的请求元数据的信息,最后测试发现是空数据,想知道requestMetadata和responseMetadata是干嘛用的,是我版本问题所以两者都是空数组?

@dbfu
Copy link
Owner

dbfu commented Dec 11, 2024

认证中间件比对这里 this.notLoginRouters.some( o => o.requestMethod === routeInfo.requestMethod && o.url === routeInfo.url ) 应该还要添加一个前缀的比对 o.prefix === routeInfo.prefix, 否则有不同prefix下,相同的url和请求方法会匹配到. 另外我有个疑问,我看作者大大的blog最开始是比对requestMetadata,我理解requestMetadata应该是路由表中设定的请求元数据的信息,最后测试发现是空数据,想知道requestMetadata和responseMetadata是干嘛用的,是我版本问题所以两者都是空数组?

是的,加上这个判断会更好。o.prefix === routeInfo.prefix。requestMetadata和responseMetadata这两个是干嘛用的我也不清楚。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants