In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "how to solve the problem that options cannot be queried by cas". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
I. Development environment
Vue springmvc cas
Second, problem description
$http.post with a request header of 'Content-Type':' application/json;charset=utf-8' does not normally query data and always returns 302, so it is not good to add any filter to the tutorials on the reference network. All kinds of speculation have been going on for several days.
Access to XMLHttpRequest at 'http://127.0.0.1:10010/wyxt_ubqts_oncloud/docDetail/checkDocList' from origin' http://127.0.0.1:2019' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
III. Problem solving
Through custom filter filtering options requests can not be intercepted after cas, and the header set before cas is not good, so we have to modify cas's filter, decompile AuthenticationFilter, copy content, and create a new CasAuthenticationFilter class.
Add at the beginning of the doFilter method
Response.setHeader ("Access-Control-Allow-Credentials", "true"); response.setHeader ("Access-Control-Allow-Origin", request.getHeader ("origin")); response.setHeader ("Access-Control-Allow-Methods", "OPTIONS,HEAD,DELETE,GET,PUT,POST"); response.setHeader ("Access-Control-Max-Age", "1728000") Response.setHeader ("Access-Control-Allow-Headers", "Origin,X-Requested-With,Content-Type,Accept,Authorization,WG-App-Version,WG-Device-Id,WG-Network-Type,WG-Vendor,WG-OS-Type,WG-OS-Version,WG-Device-Model,WG-CPU,WG-Sid,WG-App-Id,WG-Token")
The configuration of web.xml is changed from AuthenticationFilter to CasAuthenticationFilter.
Restart, data normal request!
This is the end of the content of "how to solve the problem that 302 cannot be queried due to the interception of options by cas". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.