gpt4 book ai didi

java - CORS : Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request

转载 作者:行者123 更新时间:2023-11-30 10:02:49 47 4
gpt4 key购买 nike

<分区>

我正在尝试将 angualar js 应用程序与后端 spring boot 集成,其中我面临着预检请求不允许重定向

这是在 openshift 上部署的,我已经通过在 Controller 方法中添加一些注释来配置启用 cors,这帮助我解决了: 请求在传入请求中没有“Access-Control-Allow-Origin” header :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);
}

我在实际角度应用程序中得到的错误是:

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.

选项调用已返回以下响应:

    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

47 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com