Is there a way to set custom http headers in the prismic javascript client?

Hi There,

My organization requires me to run all http requests (and so also Prismics api requests) through a proxy.

This proxy requires me also to send a custom http header along with the http request.

Doest the prismic JS client support setting headers in anyway?

Thank you

Hey @jgoddijn ,

When you initialize your Client, you can specify a few options. I'm not sure if any of them would be directly useful to you. When you initialize your Client, you can specify an options object:

const Prismic = require('prismic-javascript')
const endpoint = ''
const accessToken = "secret-access-token"
const Client = Prismic.client(endpoint, { accessToken })

The options object can accept these options:

  • accessToken
  • routes
  • requestHandler
  • req
  • apiCache
  • apiDataTTL
  • proxyAgent
  • time

The client is based on node-fetch, and proxyAgent refers to the agent option in that package. Let me know if that helps. (I'm not familiar with proxies, so this is just a guess.) If this doesn't address your use case, I can keep digging.


This issue has been closed due to inactivity. Flag to reopen.