New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trouble setting up feathers/client #262
Comments
For superagent and any other support REST library you can also set
In the feathers-authentication client we are using that in a hook. The problem with Request here is probably that the headers get overwritten now by those settings (even when they are empty). |
Awesome! 😄 This worked perfectly. Ended up going with this: import feathers from 'feathers/client';
import rest from 'feathers-rest/client';
import hooks from 'feathers-hooks';
import superagent from 'superagent';
import User from 'app/utilities/user';
import config from './config';
const app = feathers()
.configure(hooks())
.configure(
rest(config.host).superagent(superagent)
);
function authHook(hook) {
hook.params.headers = Object.assign({}, {
Authorization: `Bearer ${User.get().token}`
}, hook.params.headers);
}
export default {
service(url) {
let s = app.service(url);
s.before({
all: authHook
});
return s;
}
}; |
Looks great! One other thing you could do is make it a service mixin so it will get added to all services automatically: app.mixins.push(function(service) {
service.before(authHook);
}); Mixins are not publicly documented yet but it's what all the plugins use to hook into a service. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue with a link to this issue for related bugs. |
I have the following code
However, when I call
create
on a service it does not send theAuthorization
header.Alternatively, how can I set up feathers with superagent to send along specific headers?
Thanks!
The text was updated successfully, but these errors were encountered: