feat: Authentication token refresh logic
This commit is contained in:
@@ -2,10 +2,10 @@ import { defu } from "defu";
|
||||
|
||||
export default defineRemoteExecutorHooks({
|
||||
onRequest(request, context) {
|
||||
// Attach the Authorization header if a wpAuthToken is present in the context
|
||||
if (context?.wpAuthToken) {
|
||||
// Attach the Authorization header if an authToken is present in the context
|
||||
if (context?.authToken) {
|
||||
request.extensions = defu(request.extensions, {
|
||||
headers: { Authorization: `Bearer ${context.wpAuthToken}` },
|
||||
headers: { Authorization: `Bearer ${context.authToken}` },
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user