Asset function of the Laravel is not referencing

Asked

Viewed 787 times

0

I have a project and I honestly do not know what I did differently, but at the time of opening it, out of the blue all images, files css and javascript are not being referenced.

I’m using the laravel, and referencing as follows:

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

When I open the browser console, I come across an error for each image, file css or javascript, of the kind:

Failed to load Resource: the server responded with a status of 404 (Not Found) http://localhost:8000/css/bootstrap.css

The files are inside the folder projeto/laravel/public, how it should be and how it always worked.

I’ve tried going back to previous versions on git but it doesn’t help.

I have tried on another computer but also no results.

Does anyone have any idea what it might be?

  • Asset goes to the Assets folder that if you are using Variable >= 5 is inside the Resources folder. Try the following {{ url('/css/bootstrap.css') }}

  • So, I just tested also passing all the files from the public folder to the Resources/Assets folder, even then it doesn’t work. I have also tried url('/css/bootstrap.css'), but to no avail. I even tried URL::Asset(') and url('Assets/'), but nothing. Thanks anyway

  • Do your other routes work normally? It wouldn’t have any impact on your public files?

  • Running the app with Artisan? or directly in the public folder?

  • @Kennyrafael yes, the other routes work normally. I even tried to revert to an older version in git, but I still couldn’t make this problem stop. I thought it might be something in apache, but I didn’t touch it. , yes, php Artisan will do

  • I would like to test it on another server, I do not know if you have a production...some errors in the Standard happened to me only in dev, more than once...

  • As you are calling the site, type the address here for example you are experiencing problem?

  • I am running it only local, I have no server for now. Testing on another server means testing on another computer, in case?

  • I’m trying the same problem, someone got a solution to the case?

Show 4 more comments

1 answer

0

I will answer that question because I had the same problem when I deployed my project for production and I couldn’t find the answer anywhere.

To set up your project’s Assets URL, you need to change ownership 'asset_url' => env('ASSET_URL', null) of your file config/app.php.

Before deploying for production, you need to change the value null to the folder where the Assets are located, ex. asset_url' => env('ASSET_URL', '/public/'). When you make this change, you need to place the property ASSET_URL = null in your file .env, so that Assets are located also under development.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.