Skip to content

请求怎么携带cookie #379

Closed Answered by Aixbox
Aixbox asked this question in Q&A
Jun 11, 2024 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

解决了,要在请求拦截器添加config.credentials = 'include'

  // 设置全局的请求拦截器,与axios相似
  beforeRequest({ config }) {
    // 假设我们需要添加token到请求头
    config.headers.Authorization = `Bearer ${computedToken.get()}`

    config.headers['Content-Type'] = 'application/json; charset=utf-8'
    config.credentials = 'include'
  },

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Aixbox
Comment options

Answer selected by Aixbox
@MeetinaXD
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants