distributor
distributor copied to clipboard
Connecting two sites on development servers
Describe your question
Hi, I am attempting to set up Distributor between two development sites that both have nginx set up with a basic authentication on top of the usual wordpress logins. Is it possible to do this in this type of an environment? I have tried various methods of creating connections but I suspect the basic auth is preventing the connection.
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
@jouni-salo You might be able to use the WordPress http_request_args filter to add an authorization header to the requests:
add_filter( 'http_request_args', function( $args, $url ) {
if ( str_contains( $url, '//xu-distributor.local/' ) ) {
$username = 'admin';
$password = 'password';
$auth = base64_encode( "$username:$password" );
$args['headers']['Authorization'] = "Basic $auth";
}
return $args;
}, 10, 2 );
You'd need to place this in the mu-plugins folder to ensure it runs prior to Distributor.
Unfortunately I don't have such an environment set up locally so I haven't been able to confirm this code works.