https://stackoverflow.com/questions/7210507/ajax-post-error-refused-to-set-unsafe-header-connection/7210840
Remove these two lines:
xmlHttp.setRequestHeader("Content-length", params.length); xmlHttp.setRequestHeader("Connection", "close");
XMLHttpRequest isn’t allowed to set these headers, they are being set automatically by the browser. The reason is that by manipulating these headers you might be able to trick the server into accepting a second request through the same connection, one that wouldn’t go through the usual security checks – that would be a security vulnerability in the browser.
//requestinterceptor
service.interceptors.request.use(
config=>{
//dosomethingbeforerequestissent
//console.log(store.getters.token)
config.headers[‘Access-Control-Allow-Origin’]=’*’
config.headers[‘cache-control’]=’max-age=1,s-maxage=1′
config.headers[‘Cookie’]=’noBy-interceptors.request’
Similar Posts:
- Ajax submitting datagram in firebox_ ERROR_ DOCUMENT_ NOT_ Cached error
- Call JIRA API to create issue prompt xsrf check failed
- The front-end XMLHttpRequest object sets an error in the request header
- [Solved] Forbidden (403) CSRF verification failed. Request aborted.
- Uncaught SyntaxError: Unexpected token o
- What is the reason why the easygbs client calls token and reports an error “refer to set unsafe header” cookie “
- XMLHttpRequest status=0 (All You Should Know)
- [Solved] Unapp H5 Error: Access to XMLHttpRequest at ‘http://www.localtest.com/api/api/v1/job/getPositionList’…
- [Solved] Uniapp Axios appears in wechat applet index.js? [SM]: 33 errortyerror: l is not a function error
- [Solved] react native TypeError: Network request failed Unable to symbolicate stack trace: The stack is null