Rendr add custom header to fetch request (such as basic auth)

102 views Asked by At

I'm building a Rendr app and I'd like to populate my user model by making a request to my API service's /login endpoint. That endpoint simply expects a basic auth header.

I see Rendr has an option to allow custom headers but the problem is the header is only added from the client to the Rendr node.js server. When the API proxy intercepts my requests and makes a call to http://my-api.com/login the basic auth header is not carried through to this request. I'm assuming the apiProxy ignores these headers- it has no way to know what header is custom.

How can I define a custom header client side and ensure the header is added to an API request?

this.app.fetcher.fetch({
    user: {
        model: 'User',
        params: {}
    }}, {
     headers': {
        "Authorization": "Basic abcdefg12345678"
    }
   }, function(err, user){

});

This example only adds a header from client -> Rendr node server, not NOT from Rendr node server --> my API service.

1

There are 1 answers

0
Chris On BEST ANSWER

I put together an npm module for this: https://www.npmjs.com/package/rendr-api-proxy-optionable that should do what you need.

It allows pass throughs of request and response headers at the api proxy level.

Hope that helps!