测试跨域html
创建一个html文件,内容如下,如能正确访问并返回则说明服务器端跨域设置正确
<script> var xhr = new XMLHttpRequest(); xhr.open('POST', 'http://192.168.62.110:8769/api-point/points'); xhr.setRequestHeader('content-type', 'application/json'); const json = { "groupId": "string", "keyword": "string", "max": 0, "min": 0, "page": 0, "size": 0 } // send rquest with JSON payload xhr.send(JSON.stringify(json)); xhr.onload = function(e) { var xhr = e.target; console.log(xhr.responseText); } </script>
json字符串可以直接从swagger-ui.html中copy最方便
签名:删除冗余的代码最开心,找不到删除的代码最痛苦!