We have an issue with a new Magento 2.4.2 site after migrating from M1 and activating 2 Factor Authentication. The QR code will not load and just displays as a broken image.
1 Answer
This turned out to be caused by an erroneous newline being added to all output. If you inspect the page source (right click => view source) on any page and you see this, then you have the same issue.
To find the offending file we used Magento's coding standards with PHP_CoderSniffer
magento@12389-php-fpm:~/htdocs$ ./vendor/bin/phpcs --standard=Magento2 app FILE: /app/path/to/file.php ------------------------------------------------------------------------------------ FOUND 1 ERROR AND 2 WARNINGS AFFECTING 3 LINES ------------------------------------------------------------------------------------ 2 | ERROR | [ ] The opening PHP tag must be the first content in the file ------------------------------------------------------------------------------------ PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY ------------------------------------------------------------------------------------ Unfortunately CodeSniifer was unable to fix the file automatically, but it was a case of changing
<?php to
<?php Then flushing cache.
N.B if the above doesn't find an error for you, you may need to also check vendor, though fixing an issue with a module in vendor would require assistance from the vendor or a patch.

