I am a newbie learning Vue.js
and I am using it with Laravel. I have decent experience with Laravel. Previously, without any frontend setup, I simply used to go to http://localhost/my-project/public
and my Laravel homepage would display as everything used to be in the public directory.
Now I am using Vue
with Vite
as my build tool. After running npm run build
, the build assets by Vite
are placed inside public/build
directory. I run the dev environment using npm run dev
and php artisan server
and I can access the app on http://localhost:8000
but how do I access my app without using Artisa or without any dev servers running?
This is my /public
directory structure:
│ .htaccess
│ favicon.ico
│ index.php
│ robots.txt
│
├───build
│ │ manifest.json
│ │
│ └───assets
│ app.5bcb0e65.js
│ app.dd96aa6d.css
..other images, fonts
Currently, When I go to the URL http://localhost/my-project/public/dashboard
, I see nothing but a blank white screen and an error in the console saying [Vue Router warn]: No match found for location with path "/my-project/public/dashboard"
but with php artisan server, I can access http://localhost:8000/dashboard
without any issues.
This is my routes\web.php
file contents:
...
Route::any('/', function () {
return view('welcome');
});
Route::any('/{slug}', function () {
return view('welcome');
})->where('slug', '([A-z\d\-\/_.]+)?');