Open
Description
I'm interacting with an API which uses query params for auth, and I'm trying to find the best way to add them on the fly. My first thought was to use middleware to modify the requests, since that's what I'm already doing to add the custom headers.
let middleware = new MiddlewareStack();
middleware.beforeFilters.push(function(url, options) {
// hard-coded example: this will actually be dynamically built, once i have a strategy for injecting params
url += '?auth_id=1&auth_token=43a3f9e8a2986cd8182ab611d0dba648&auth_timestamp=1531772824';
options.headers["Accept"] = "application/vnd.api+json"; // this works great
console.log('url', url); // this shows up in the log, but not in the outbound request
});
ApplicationRecord.middlewareStack = middleware;
But modifying the urls here doesn't seem to change the actual url being built for the request.
Is there a way to manipulate URLs before they're used? Or is there a better way to solve this problem than the middleware approach?
Thanks in advance.
Metadata
Metadata
Assignees
Labels
No labels