【发布时间】:2020-08-05 05:48:35
【问题描述】:
这是 Spring Boot 端的代码:
class FruitWrapper{
List<String> fruits;
}
class HelloController {
@PostMapping("/")
public String hello(@RequestBody FruitWrapper fruits)
{
System.out.println(fruits);
return "he";
}
}
我正在从这样的反应中发送请求:
axios.post(`${COURSE_API_URL}`,{"fruits":["apple","orange"]})
.then(resp{console.log(resp.data)})
错误:
Access to XMLHttpRequest at 'http://localhost:8081/' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
【问题讨论】:
标签: reactjs spring-boot