skip to Main Content

I am developing a Laravel project. It is under 5.7 Laravel version. I am using Homestead as a local development environment. When I run any route in the project, it doesn’t load public assets. instead, it gives 404 error. see attached image below.

I coded correctly on getting assets path

{{ asset("public/js/frontend/jquery.min.js") }}

enter image description here

but all these assets are existing in the project folder. and when i try to go any of those assets, it gives laravel’s 404 error.see below image.

enter image description here

It would be great if anyone can give me a solution for this. Thanks in advance.

2

Answers


  1. As suggested by @Douwe de Haan you don’t have to use the public part, just call

    {{ asset("js/frontend/jquery.min.js") }}
    
    Login or Signup to reply.
  2. You shouldn’t write public directory to asset function

    {{ asset("js/frontend/jquery.min.js") }}
    

    Also,

    You can configure the asset URL host by setting the ASSET_URL variable
    in your .env file. This can be useful if you host your assets on an
    external service like Amazon S3:

    // ASSET_URL=http://example.com/assets
    
    $url = asset('img/photo.jpg'); // http://example.com/assets/img/photo.jpg
    

    https://laravel.com/docs/5.8/helpers#method-asset

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search