使用 Vue.js,我尝试使用 Spring Boot 在 RESTful API 中实现 JWT 登录表单,但除非我将不记名令牌添加到请求中,否则我得到的只是 403 状态。 我已将端点设置为无需任何许可即可访问,并且在邮递员上可以在没有授权标头的情况下发送请求。 这是我在 Spring 上的安全配置的一部分:
.antMatchers(HttpMethod.POST, "/auth/login") .permitAll()
这是我发出 POST 请求的 vue.js 服务:
import axios from 'axios'
let USER_API_BASE_URL = 'http://localhost:8080/auth/login/'
let config = {
headers: {
'Content-Type': 'application/json',
'Authorization': "Bearer (hereGoesTheToken)"
}}
class LoginService{
postLogin(emailInput, passwordInput){
let user = JSON.stringify({email: emailInput, password: passwordInput});
var response = axios.post(USER_API_BASE_URL, user, config);
console.log(response)
return response
}
}
export default new LoginService()
我想要做到这一点,这样就不需要令牌就可以访问您请求相同令牌的部分...有什么方法可以做到这一点吗?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号