0

I have installed Laravel5.3 and install Auth scaffolding after that I went to register

   http://localhost/laravel53/public/register

the page is messy and no css ans js loaded correctly and in browser console I can see:

 "NetworkError: 404 Not Found - http://localhost/css/app.css" and 
 "NetworkError: 404 Not Found - http://localhost/js/app.js"

and in C:\xampp\htdocs\laravel53\resources\views\layouts\app.blade.php the link to css file is not correct

 <!-- Styles -->
<link href="/css/app.css" rel="stylesheet">

but when remove / from href the path become correct.

the question now is: Is this bug in laravel5.3 or any way to solve this issue without removing /

Ayman Hussein
  • 3,817
  • 7
  • 28
  • 48
  • If you go to `http://localhost/css/app.css` in your browser, is it there? I'll bet it's at `http://localhost/laravel53/public/css/app.css`. – ceejayoz Aug 31 '16 at 19:34
  • Possible duplicate of [Laravel assets url](http://stackoverflow.com/questions/24794601/laravel-assets-url) - use the `asset` or `url` helpers. And `public` shouldn't be in your URLs in production - your webserver should be pointed directly at it. – ceejayoz Aug 31 '16 at 19:35
  • Yes when use asset helper that fine, but my question why laravel did not use it from the beginning! – Ayman Hussein Aug 31 '16 at 19:41
  • Yes the css file in http://localhost/laravel53/public/css/app.css but laravel5.3 put /css/app.css in href so the relative path will be http://localhost/css/app.css and this path is not correct – Ayman Hussein Aug 31 '16 at 19:43
  • Laravel is meant to be run at the root of a domain. It is not meant to have a base path of `laravel53/public` like you have. This is why Laravel provides `php artisan serve` and Laravel Valet / Laravel Homestead - to make such things easier on people. Either way, this should be trivial for you to debug on your own. – ceejayoz Aug 31 '16 at 19:48
  • But they should cover all cases like this case and put general way to be fit in the project run on root or even inside folder like my case. – Ayman Hussein Aug 31 '16 at 19:59
  • They can't possibly cover all "you shouldn't have done that" cases, nor should they waste the time. Laravel's for developers, who should be able to troubleshoot stuff like this and set it up responsibly. – ceejayoz Aug 31 '16 at 20:01
  • Thank you @ceejayoz – Ayman Hussein Aug 31 '16 at 20:08

1 Answers1

2

In layout css path is hardcoded to '/css/app.css'. Please replace it with this {{url('/css/app.css')}}

Rashi Goyal
  • 933
  • 9
  • 15