z0mt3c / hapi-swaggered

Yet another hapi plugin providing swagger compliant API specifications based on routes and joi schemas to be used with swagger-ui.
MIT License
82 stars 38 forks source link

How to add header to request? #165

Open vforv opened 7 years ago

vforv commented 7 years ago

Is there any way to send also header with requests?

m1m1s1ku commented 6 years ago

The only way i found to achieve this is to set a requestInterceptor in the swagger-ui init (in index.hbs of hapi-swaggered-ui) : Something like this in the SwaggerUIBundle(Object.assign({....

requestInterceptor: (req) => {
      req.headers.Authorization = 'Bearer ' + localStorage.getItem('token');
      return req;
},