tractr / directus-sync

A CLI tool for synchronizing the schema and configuration of Directus across various environments.
GNU General Public License v3.0
209 stars 8 forks source link

Add support for client hooks #84

Closed Khartir closed 2 months ago

Khartir commented 2 months ago

Is your feature request related to a problem? Please describe. Our directus instances are behind a firewall. To access them, we need to send some additional headers in the request.

Describe the solution you'd like I previously tried to sync using the directus sdk directly. There I could add the headers in the onRequest-hook of the rest-client:

const addAuth = (request) => ({
        ...request,
        headers: {
            ...request.headers,
            'access-token': 'foo',
        },
    });
const client = createDirectus('url').with(rest({ onRequest: addAuth }));

It would be nice, if there was an option to configure the client and do the same here.

Describe alternatives you've considered I tried modifying the client in the onDump hook but it seems there are some requests that are sent earlier.

Additional context I think I could add this myself, would you be interested in a pull request for this?

EdouardDem commented 2 months ago

@Khartir This is a good idea and does not seems to difficult to implement. I will check this in few weeks.