payment methods – how to redirect to external url from observer sales_order_place_after

I want to redirect to my external payment method after place order is Saved, I create an observer for event sales_order_place_after.

Inside execute I put this code

$this->responseFactory->create()->setRedirect($this->url->getUrl(//ExternalURL like http://localhost))->sendResponse();

but I get an error cors and I don’t know how to fix or an alternative to redirect with dynamic variables inside URL like http://localhost/example?variable1=example