首页 > 解决方案 > NuxtJS/apollo 如何设置自定义标头

问题描述

如何在@nuxtjs/apollo 上设置自定义标题?

on my nuxt.config.js

我有这样的东西

apollo: {
  "x-token": "hash",
  "x-auth-token": "hash",
  "x-refresh-token":  "hash",
  headers: {
  },
  clientConfigs: {
    default: {
      // required
      httpEndpoint: "localhost:4000"
    }
  }
}

谢谢

标签: vuejs2nuxt.jsvue-apollo

解决方案


像这样:

nuxt.conifg.js

apollo: {
  clientConfigs: {
    default: {
      httpEndpoint: 'localhost:4000',
      httpLinkOptions: {
        headers: {
           'x-token': 'hash',
           'x-auth-token': 'hash',
           'x-refresh-token':  'hash'
        }
      }
    }
  }
},

推荐阅读