mirego / accent

The first developer-oriented translation tool. True asynchronous flow between translators and your team.
https://www.accent.reviews
BSD 3-Clause "New" or "Revised" License
1.25k stars 96 forks source link

Extra Headers support in CLI #430

Open DaniFoldi opened 4 months ago

DaniFoldi commented 4 months ago

Hi :wave:,

I'm opening this issue to ask if a new config option extraHeaders would be interesting. In our setup (behind Cloudflare Access) any programmatic access needs to provide two extra headers, provided as environment variables to the Docker container. In an effort to get rid of our mitm proxy in CI that just adds the headers to all requests, I was instead looking at a native solution.

To me it looked like the only place this needs to be added (in the CLI, since all the rest is inside the docker container that is the application behind Access) is here in project-fetcher.ts: https://github.com/mirego/accent/blob/58b78e29b44da3dd39cc332a2b52844642509e5a/cli/src/services/project-fetcher.ts#L114-L121 and a few places in document.ts - in this second case the simplest solution would be to (add it to config, pass it the Document class) and add it the the private authorizationHeader() method: https://github.com/mirego/accent/blob/58b78e29b44da3dd39cc332a2b52844642509e5a/cli/src/services/document.ts#L248-L250; alternatively the couple of places that call fetch() could all be modified, which one would be preferable?

In general, would this extra headers feature be something you would be interested in supporting? Happy to work on a PR implementing it.

simonprev commented 3 months ago

Sure I’m open to a PR addressing thing 😃