Open anatel opened 5 years ago
good catch...should have documented those options: https://github.com/i18next/i18next-xhr-backend/blob/master/src/ajax.js#L55
// custom request headers sets request.setRequestHeader(key, value)
customHeaders: {
authorization: 'foo',
// ...
},
Thanks, I have a token that can change from one call to another, so I can't just pass a string, i want to pass it something dynamic, maybe a function.
I understand that loadPath
can get a function, can customHeaders
get a function as well?
Or is there any way to change this middleware's config after the init phase?
You should be able to modify backend.options, something like:
i18next.services.backendConnector.backend.options.customHeaders = { .... }
Great, thanks!
This still isn't ideal, could it be made to accept a headers function also? Trying to make this as declarative as possible..
Is it possible to configure the request header and add authorization token before it is sent?