There is an extra field MIME type in the safari post request data

< H2 > there is an extra field "MIME type" in the safari post request data, while chrome is normal < / H2 >.

recently encountered a strange problem in development, turn to the gods!

the project framework is vue, the request is axios, and the background is Java. I encapsulated a layer of methods on axios to do unified interface processing, and all requests in the project are called this method. When axios sends a request to the background, the chrome browser is normal, but the safari browser has a field "MIME type" in the request data, but this field is not set by me

chrome browser is correct

clipboard.png

safari"MIME"

clipboard.png

< hr >

here is my request method based on axios encapsulation

import qs from "qs"
import axios from "axios"
import signature from "../module/signature"

const request = axios.create({
  timeout: 50000,
  withCredentials: true
})

// POST
request.interceptors.request.use(function (config) {
  if (config.method === "post" || config.method === "put" || config.method === "delete") {
    // 
    config.data = qs.stringify(config.data)
  }
  return config
}, function (error) {
  console.log(error)
  return Promise.reject(error.data.msg)
})

// 
request.interceptors.response.use(function (response) {
  let res = response.data
  // 
  if (res.resultCode !== 200 && res.errorCode !== 0) {
    console.log(res.msg, res.resultCode)
  }
  return Promise.resolve(response.data)
}, function (error) {
  console.log(error)
  if (error.message === "Network Error") {
    console.log(error.toString())
    return
  }
  return Promise.reject(error)
})

export default async (url, data, method = "get") => {
  // 
  const timestamps = new Date().getTime()
  // 
  method = method.toLowerCase()

  // 
  let requestUrl = url

  // 
  try {
    let response = await request[method](requestUrl, method === "post" ? data : { params: data })
    response.request = {
      url,
      data,
      method,
      timestamps
    }
    return Promise.resolve(response)
  } catch (error) {
    return Promise.reject(error)
  }
}
Jul.08,2021
Menu