localhost and 127.0.0.1 are the same machine and different origins. Magento writes static file URLs from the base URL. If you open the admin on one host while the base URL uses the other, CSS, JS, and requirejs 404 or get blocked, and the admin looks unstyled. Pick one host and store that host in the base URL.
Paste each static file URL into the URL Parser and compare the host, scheme, and port. The host that does not match the address bar is the one stored in the base URL.
Content-Security-Policy messages in the same console are a second problem. Fix the host first. A CSP report does not mean the static file was the wrong host.
http://localhost/.../admin and the network panel requests http://127.0.0.1/static/adminhtml/..., or the reverse.
Browsers compare scheme, host, and port. The same-origin policy treats http://localhost and http://127.0.0.1 as different sites. Cookies set for one are not sent to the other. Magento’s admin form key and session live in that cookie, so a mixed host also produces “invalid form key” after login redirects.
Static URLs are not guessed from the address bar. They come from web/unsecure/base_url and web/secure/base_url.
http://localhost/ is fine for a single local site. A named host such as http://shop.test/ is better once you have two projects.php bin/magento config:show web/unsecure/base_url
php bin/magento config:show web/secure/base_url
php bin/magento config:set web/unsecure/base_url http://localhost/
php bin/magento config:set web/secure/base_url http://localhost/
Use https://shop.test/ when TLS is actually terminating. Do not set the secure URL to https://127.0.0.1/ while you browse http://localhost/.
php bin/magento cache:flush
In developer mode, static files are generated on request. In production mode, redeploy:
php bin/magento setup:static-content:deploy -f en_US
Add your real locale codes. -f is required in developer mode; omit the force flag in production if the command accepts the run without it.
In the browser network panel, open a failed stylesheet and read the request host. It must match the host in the address bar, including localhost versus 127.0.0.1 and http versus https. A file that returns 200 from the other host is still the wrong origin.
View source on the admin login page. Every static/adminhtml URL starts with the same scheme and host as the address bar. The network panel shows 200 for css/styles.css and requirejs/require.js. The login form posts back to that same host.
core_config_data has a store-scope row that still points at the other host. config:show prints the merged value; check the table if a website scope overrides default.app/etc/env.php does not cause this by itself. A CDN or pub/static rewrite might. The network panel is the authority.localhost to ::1 first. If only IPv4 is listening, browse 127.0.0.1 and set the base URL to http://127.0.0.1/, or make Apache listen on IPv6. Do not mix them..localhost or a parent you do not use. Set web/cookie/cookie_domain empty for a single local host.No. Browsers compare scheme, host, and port. Those two hosts do not share cookies or pass a cross-origin stylesheet.
Static URLs come from the saved base URL, not from the address bar. config:show is the check.
Not by itself. Fix the host first. A report-only CSP line can be a second message in the same console.