当我通过axios发布一些数据时,出现了cors和网络错误。如何解决此错误?

时间:2019-06-13 07:35:39

标签: javascript laravel vue.js cors axios

发布数据时,出现两个错误。 我该如何解决错误。(这是laravel的api)

  1. 更正错误?
  2. 网络错误

我在axios config的标题中添加了一些代码。 就像... X-Requested-With

axios.interceptors.request.use(config => {
  setAccessToken(config);
  config.headers['X-XSRF-TOKEN'] = getCookieValue('XSRF-TOKEN')
  config.headers['X-Requested-With'] = 'XMLHttpRequest'
  config.headers['Content-Type'] = 'application/json'
  config.headers['withCredentials'] = true

  return config
})

这些是错误。

Mixed Content: The page at 'https://xxx/login' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://xxx/'. This request has been blocked; the content must be served over HTTPS.
app.js?id=.... err auth login =  Error: Network Error
    at LYNF.e.exports (app.js?id=....)
    at XMLHttpRequest.u.onerror (app.js?id=....)

0 个答案:

没有答案