【java – Angular 5:预检的响应具有无效的HTTP状态代码403】教程文章相关的互联网学习教程文章

java – spring CORS和angular not working:HTTP状态码403错误【代码】

我是角度和弹簧安全的新手.当我尝试使用基本身份验证从角度登录表单页面登录到其余端点时,我遇到CORS问题.我的Angular代码在http://localhost:4200运行,休息结束点在http://localhost:8181.我的angular login-form尝试向我在登录控制器中指定的http://localhost:8181/token发出请求.即使我在服务器端添加了cors配置,我也会收到此错误: – 无法加载http://localhost:8181/token:对预检请求的响应未通过访问控制检查:请求的资源上...

java – Angular 5:预检的响应具有无效的HTTP状态代码403【代码】

当我向服务器发送POST请求时,我收到一个错误:Failed to load http://localhost:8181/test: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access. The response had HTTP status code 403.后端是用Java Spring编写的.我创建测试的方法:createTest() {const body ...

javascript – 如果状态代码在angularjs中为403,则退出【代码】

我有一个SPA(单页面应用程序),它向服务器发送大量的http请求,服务器检查发送请求的用户是否经过身份验证. 如果用户未经过身份验证,我会将其重定向到这样的登录页面:$scope.getGroups = function () {$http({method: "get",url: "/enterprises/groups"}).success(function (response) {GroupService.updateGroups(response.groups);}).error(function (errResponse, status) {if(status == 403){$location.path("login")}}); };问题...