
Access to XMLHttpRequest at 'https://aip.baidubce.com/oauth/2.0/token' from origin 'http://localhost:8000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
- uni.request({
- url: 'https://aip.baidubce.com/oauth/2.0/token',
- })
-- manifest.json里的h5配置项如下配置:
- "h5" : {
- "devServer" : {
- "port" : 8000,
- "disableHostCheck" : true,
- "proxy" : {
- "/baiduApi" : {
- "target" : "https://aip.baidubce.com", // 需要跨域的域名
- "changeOrigin" : true,
- "secure" : false,
- "pathRewrite" : {
- "^/baiduApi" : ""
- }
- }
- }
- },
- }
-- 调用url处如下写:
- uni.request({
- url: '/baiduApi/oauth/2.0/token',
- })