I've created a block that displays a Moodle form, and the entire form processing works fine, but after the form has been processed, the user is taken back to the course page without the proper url displayed, just `mysite.edu/course/view.php` with no course id.
The standard solution, shown in the dev docs (see https://docs.moodle.org/dev/Blocks_Advanced#Form_State_Control) would be to use the `redirect` funtion back to the course url after the form is processed. As far as I can recall, this worked in previous Moodle versions, but in Moodle 3.10, this function throws an error: "Coding error detected, it must be fixed by a programmer: You cannot redirect while printing the page header"
The other workaround that I've tried is to user `$PAGE->set_url`, and while this doesn't throw an error, it also doesn't update the url successfully.
What is the proper way to set the page url after a block form has been submitted?