Santiago Ramirez
Santiago Ramirez

Reputation: 317

error 404 using a local google font on laravel

I'm working with laravel in a project and I downloaded a google font using the google-webfonts-helper app to use the font offline, but i'm getting this error in my browser:

GET http://127.0.0.1:8000/css/public/fonts/nunito-v14-latin-800.woff2 net::ERR_ABORTED 404 (Not Found)

this is the css call

<link href="{{asset('css/fonts.css')}}" rel="stylesheet">

and this is a part of fonts.css file (i didn't put all the code because it's basically the same just different font weights)

@font-face {                  
    font-family: 'Nunito';
    font-style: normal;
    font-weight: 200;
    src: url('public/fonts/nunito-v14-latin-200.eot');
    /* IE9 Compat Modes */
    src: local('Nunito ExtraLight'), local('Nunito-ExtraLight'), url('public/fonts/nunito-v14-latin-200.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
    url('public/fonts/nunito-v14-latin-200.woff2') format('woff2'), /* Super Modern Browsers */
    url('public/fonts/nunito-v14-latin-200.woff') format('woff'), /* Modern Browsers */
    url('public/fonts/nunito-v14-latin-200.ttf') format('truetype'), /* Safari, Android, iOS */
    url('public/fonts/nunito-v14-latin-200.svg#Nunito') format('svg');
    /* Legacy iOS */
}

I pasted the fonts files in public/fonts, the browser actually recongizes the css file but I dont know what i'm doing wrong

Upvotes: 2

Views: 1573

Answers (1)

Muhamad Rafi Pamungkas
Muhamad Rafi Pamungkas

Reputation: 308

in laravel the url function is rooted in the public folder.
So if you paste your font file into public/font/file.ttf
please use url('font/file.ttf') instead of url('public/font/file.tff').
Because it will point to the public/public/font/file.ttf file

Upvotes: 2

Related Questions