setAuthorization.ts 425 B

123456789101112131415
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { setContext } from '@apollo/client/link/context'
  3. import { getCSRFToken } from '../utils/csrfToken.ts'
  4. const setAuthorizationLink = setContext((request, { headers }) => ({
  5. headers: {
  6. ...headers,
  7. // Fetch CSRF from head via html embed from Rails.
  8. 'X-CSRF-Token': getCSRFToken(),
  9. },
  10. }))
  11. export default setAuthorizationLink