Android报错-跨域问题CORS-Request header field x-app-version is not allowed by Access-Control-Allow-Headers in preflight response
- 更多其他页面-自定义View-实用功能合集:点击查看
报错如何出现?
使用的是nannoHttpD实现的微服务加载本地html,其中有跨域请求
`
报错原因
没有允许跨域请求
报错如何解决?
还没有解决啊!!!!!先记录一下各种办法以及跨域知识文档
HashMap<String, String> hashMap = new HashMap<>();
// hashMap.put("Access-Control-Allow-Origin", "http://127.0.0.1:8080");
hashMap.put("Access-Control-Allow-Origin", "*");
hashMap.put("Access-Control-Max-Age", "3628800");
hashMap.put("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
hashMap.put("Access-Control-Allow-Credentials", "true");
hashMap.put("Access-Control-Allow-Headers", "x-requested-with,x-app-version,Authorization,Content-Type");
webView.loadUrl(url,hashMap);
Android 中加载本地Html 跨域问题,http协议允许加载
反射设置 setAllowUniversalAccessFromFileURLs true
关于在android平台使用nanohttpd实现的http服务在WIFI环境下响应明显太慢的问题
Android技术生活交流
微信
![]()