fullstack-boilerplate
fullstack-boilerplate copied to clipboard
feat: Default authentication in Villus context
While the full login service is developed, I would appreciate it if we could have a basic auth setup for Villus based on default creds. Run the below function and then set context in Villus. Although I'm struggling to set the context after getting the token.
https://github.com/logaretm/villus/issues/71
async function logInto() {
const logData = await useMutation(LoginDocument).execute({
email: '[email protected]',
password: 'changeme',
});
// Code to set context on Villus client for future requests.
}
logInto();
Looks like context in Villus has been depreciated. Any idea how you'd go about setting an Auth header with Villus after the Login Mutation?
See https://villus.logaretm.com/guide/plugins#example:-adding-authorization-headers
The credentials (i.e. default token) should be stored in an environment variable which would serve as a feature flag for this use case. Maybe AUTH_DEFAULT_TOKEN ?