Android webview loads h5 page API to request an error

mixed development:

API request error in Android webview in Huawei Glory V8
Failed to load http://XXX/API/Login/Password: Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response.

but access is normal in chrome, and so are other Android phones. Do any bosses know why?

the cross-domain problem of ps: has been solved in the background, and all other phones can access it normally. in preflight response . I think this is the key, but I don"t know exactly what the reason is

.
Apr.03,2021

first of all, I would like to thank all of you upstairs for your patient answers. This problem has been solved. header ('Access-Control-Allow-Headers:*) has been set at the backend, and has been changed to header (' Access-Control-Allow-Headers:Authorization,x-requested-with,content-type). is fine. Although I think * contains everything, there is a problem with the webview that comes with vivo's system, and there is the same problem with a Huawei Glory V8 on hand, but the p20 can be accessed normally, so the exact reason is still unclear, but write down the solution in the hope that it can help people who encounter the same problems.


Cross-domain problems caused by the same origin policy of the browser. Type the red error prompt into the browser and you will get the answer.


reminds you that you are cross-domain, which may be caused by different security policies of the webview kernel, so you have to deal with cross-domain.
reference:
https://www.cnblogs.com/cdemo.

after consulting the data, it is found that some models of Huawei are due to the setting problem of webview. If you can change it, set
webview:
webView.getSettings (). SetAllowUniversalAccessFromFileURLs (true);

.

clipboard.png


the server does not allow the Authorization field in the request header. Add

to the cors of the server.
Menu