I've my Laravel javascript file in public/js folder and it is referred like follows.
<script src="{{ asset('public/js/test.js') }}"></script>
But it is still not found 404.
I've my Laravel javascript file in public/js folder and it is referred like follows.
<script src="{{ asset('public/js/test.js') }}"></script>
But it is still not found 404.
You shouldn't need to include public
in the URL. This should work fine;
<script src="{{ asset('/js/test.js') }}"></script>
What is ASSET_URL value? You can check it in the web developer tool in chrome or firefox. 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 (https://laravel.com/docs/7.x/helpers#method-asset). For eg
// ASSET_URL=http://example.com/assets
asset('public/js/test.js') //http://example.com/assets/js/test.js
Usually your run your server document root as public folder. Hence, I am guessing that removing the public dir path will solve 404 file not found error i.e change to.
<script src="{{ asset('js/test.js') }}"></script>
Please use instead of as public folder is added Automatically by asset