SukhchainSingh88's avatar

Laravel asset() is not showing the file properly

In my laravel project i am trying to get js file though asset('js/app.js') which is inside public folder. it is working fine on localhost but on server it is not picking file. It is working on another server. I think there is any issue with htaccess file.

I try to use url() and URL::asset() but not working. I checked source of page link is perfect but still fail to pick file

I want to access that js file.

0 likes
3 replies
Nakov's avatar

@sukhchainsingh88 try starting with a forward slash in case you are in a different route, so it will try to use the absolute path:

asset('/js/app.js')
1 like
tisuchi's avatar
tisuchi
Best Answer
Level 70

@sukhchainsingh88

Try asset('public/js/app.js'), and find a way to serve your site from the public, not from root.

asset('public/js/app.js')
2 likes
szajens's avatar

Does 'asset' work for you in the latest version 10.0.3? It worked for me in version 9, but doesn't work in 10.0.3.

Edit: The issue I was experiencing was due to the lack of configuration for 'asset' in the config/app.php file.

2 likes

Please or to participate in this conversation.