Created
April 10, 2024 20:12
-
-
Save benpoorker/39f5a9acbbb2882778ace0ef93cabb4b to your computer and use it in GitHub Desktop.
Fix Laravel Valet favicon 404
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://github.com/laravel/valet/issues/375#issuecomment-629801919 | |
Nginx is looking for a favicon.ico file at the root level. | |
Instead, for Laravel projects, it should look in the public folder. | |
Just add /public on the files paths inside your config file, and run valet restart: | |
location = /public/favicon.ico { access_log off; log_not_found off; } | |
location = /public/robots.txt { access_log off; log_not_found off; } | |
If you have run valet secure, you'll find your app's config file here: ~/.config/valet/nginx/your_app.test | |
Otherwise, the default valet nginx config file is located here: | |
/usr/local/etc/nginx/valet/valet.conf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Perfect! This does the trick.
If you need to update all the projects, you can run this sed command.
Bash
sed -i 's|location = /favicon.ico|location = /public/favicon.ico|g; s|location = /robots.txt|location = /public/robots.txt|g' /etc/nginx/valet/valet.conf
or ZSH / Mac
sed -i '' 's|location = /favicon.ico|location = /public/favicon.ico|g; s|location = /robots.txt|location = /public/robots.txt|g' /etc/nginx/valet/valet.conf
And then:
valet restart
And problem solved!