AngularJS & Spring Security with ROLE_ANONYMOUS still returns 401

前端 未结 1 532
忘了有多久
忘了有多久 2021-01-23 05:27

We are building an Angular Material application, consuming a RESTful Spring MVC API, with Spring Security & OAUTH2.

For testing purpose, we gave ROLE_ANONYMOUS acce

1条回答
  •  -上瘾入骨i
    2021-01-23 05:34

    Ok, after reviewing the screenshot, we noticed the method was OPTIONS instead of POST.

    The problem was not in the headers (we were checking those so much that we weren't seeing the obvious), but in the pre-flight request OPTIONS due to CORS. Here's a nice article about it. Our Spring Security was configured for the POST method, but not for the OPTIONS. We changed it and now it works like a charm:

      
      
    

    0 讨论(0)
提交回复
热议问题