简体   繁体   English

CORS:对预检请求的响应未通过访问控制检查:预检请求不允许重定向

[英]CORS : Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request

I am trying to integrate the angualar js app with the backend spring boot , in which i am facing the redirection is not allowed for a preflight request我正在尝试将 angualar js 应用程序与后端 spring boot 集成,其中我面临着预检请求不允许重定向

This is deployed on openshift , i have configured to enabled cors by adding few annotation in the controller method , which helped me to solve the : Request doesnot have "Access-Control-Allow-Origin" header in the incoming request : CORS policy issue.这是部署在 openshift 上,我通过在控制器方法中添加一些注释来配置启用 cors,这帮助我解决了:请求在传入请求中没有“Access-Control-Allow-Origin”标头:CORS 策略问题。

    @CrossOrigin(allowedHeaders = "*", origins = "*", exposedHeaders = 
        "Access-Control-Allow-Origin", methods = {
          RequestMethod.POST, RequestMethod.GET, RequestMethod.PUT, 
    RequestMethod.DELETE, RequestMethod.HEAD,
          RequestMethod.OPTIONS, RequestMethod.PATCH, RequestMethod.TRACE })
    @RestController
    public class Controller {

   @Autowired
   Service botService;

   @Autowired
   Environment env;

   @CrossOrigin()
   @RequestMapping(value = "/jwtToken", method = {
                 RequestMethod.POST }, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
   @ResponseStatus(HttpStatus.OK)
   public ResponseEntity<UnifiedService> botConntor(                     
                 @RequestBody UnifiedInput input, HttpServletRequest request) {
          UnifiedBPMService output = botService.processBotRequest(input, request);
          return new ResponseEntity<UnifiedService>(output, HttpStatus.OK);
   }

The error which i get in the actual angular app is:我在实际的角度应用程序中得到的错误是:

Access to XMLHttpRequest at 'http:///chatbot/api/jwtToken' from origin 'http://' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request. CORS 策略已阻止从源“http://”访问“http:///chatbot/api/jwtToken”处的 XMLHttpRequest:对预检请求的响应未通过访问控制检查:预检不允许重定向要求。

The options call has returned the below respose :选项调用返回了以下响应:

    Request URL: http://<domain>/chatbot/api/jwtToken
    Request Method: OPTIONS
    Status Code: 302 Found
    Remote Address: 10.235.222.220:80
    Referrer Policy: no-referrer-when-downgrade

Your backend is redirecting (302) instead of sending a proper response (200) to the OPTIONS/preflight request.您的后端正在重定向 (302) 而不是向 OPTIONS/预检请求发送正确的响应 (200)。 Check your backend logs to see why it is redirecting.检查您的后端日志以了解其重定向的原因。 It may be something like Spring security denying the OPTIONS request and redirecting to your login page.它可能类似于 Spring security 拒绝 OPTIONS 请求并重定向到您的登录页面。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 CORS 问题 - 对预检请求的响应未通过访问控制检查: - CORS issue - Response to preflight request doesn't pass access control check: CORS 策略:对预检请求的响应未通过访问控制检查:它没有 HTTP ok 状态 - CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status CORS 策略已阻止从源访问 XMLHttpRequest:对预检请求的响应未通过访问控制检查: - Access to XMLHttpRequest from origin has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Spring 启动,安全 Cors 配置问题:对预检请求的响应未通过访问控制检查:它没有 HTTP ok 状态 - Spring boot, security Cors configuration problem: Response to preflight request doesn't pass access control check: It does not have HTTP ok status 已被 CORS 策略阻止:对预检请求的响应未通过访问控制检查:它没有 HTTP 正常状态 - has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status Spring 引导 OAuth CORS 问题 - 对预检请求的响应未通过访问控制检查:它没有 Z2993C86Z2A 状态5F788 - Spring Boot OAuth CORS Problem - Response to preflight request doesn't pass access control check: It does not have HTTP ok status 如何修复对预检请求的响应未通过访问控制检查:否&#39;Access-Control-Allow-Origin&#39;? - How to fix Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin'? 对预检请求的响应未通过访问控制检查:不存在“Access-Control-Allow-Origin”标头 - Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present ReactJS和Java:对预检请求的响应未通过访问控制检查 - ReactJS & Java: Response to preflight request doesn't pass access control check 对预检请求的响应未通过访问控制检查:不存在“Access-Control-Allow-Origin”标头。 服务器错误 - Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present . Server error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM