"message":"Invalid login","code":@feathersjs/authentication-local 在 windows 中而不在 linux 或 mac 中为 401
"message": "Invalid login", "code": 401 for @feathersjs/authentication-local in windows while not in linux or mac
当我提取在 Mac 中运行良好的项目的工作代码时,在 windows
中进行身份验证时出现此错误
错误
{
"name": "NotAuthenticated",
"message": "Invalid login",
"code": 401,
"className": "not-authenticated",
"errors": {}
}
post请求
{
"strategy": "local",
"username": "demo",
"password": "demo"
}
default.json
"authentication": {
"entity": "user",
"service": "users",
"secret": "2wVrC38R9sUb6Cjhuhoir3oate0=",
"authStrategies": [
"jwt",
"local"
],
"jwtOptions": {
"header": {
"type": "access"
},
"audience": "https://yourdomain.com",
"issuer": "feathers",
"algorithm": "HS256",
"expiresIn": "1d"
},
"local": {
"usernameField": "username",
"passwordField": "password"
}
},
所以本地策略根本不起作用
来自文档feathers doc
"Important: If you want to set the value of usernameField to username in your configuration file under Windows, the value has to be escaped as \username (otherwise the username environment variable will be used)"
因此 default.json 中的代码更改要求是
"local": {
"usernameField": "\username",
"passwordField": "password"
}
当我提取在 Mac 中运行良好的项目的工作代码时,在 windows
中进行身份验证时出现此错误错误
{
"name": "NotAuthenticated",
"message": "Invalid login",
"code": 401,
"className": "not-authenticated",
"errors": {}
}
post请求
{
"strategy": "local",
"username": "demo",
"password": "demo"
}
default.json
"authentication": {
"entity": "user",
"service": "users",
"secret": "2wVrC38R9sUb6Cjhuhoir3oate0=",
"authStrategies": [
"jwt",
"local"
],
"jwtOptions": {
"header": {
"type": "access"
},
"audience": "https://yourdomain.com",
"issuer": "feathers",
"algorithm": "HS256",
"expiresIn": "1d"
},
"local": {
"usernameField": "username",
"passwordField": "password"
}
},
所以本地策略根本不起作用
来自文档feathers doc
"Important: If you want to set the value of usernameField to username in your configuration file under Windows, the value has to be escaped as \username (otherwise the username environment variable will be used)"
因此 default.json 中的代码更改要求是
"local": {
"usernameField": "\username",
"passwordField": "password"
}