The issue you're experiencing is a common one when setting up Vite with Laravel. The message you're seeing is the default Vite development server page, which indicates that Vite is running correctly, but you need to ensure that your Laravel application is properly configured to use Vite for asset management.
Here's a step-by-step solution to resolve this issue:
-
Ensure Vite is Installed and Configured: Make sure you have Vite installed and configured in your Laravel project. You should have a
vite.config.jsfile in the root of your project. -
Check Your
vite.config.js: Ensure that yourvite.config.jsis properly set up. It should look something like this:import { defineConfig } from 'vite'; import laravel from 'laravel-vite-plugin'; export default defineConfig({ plugins: [ laravel({ input: ['resources/css/app.css', 'resources/js/app.js'], refresh: true, }), ], });Adjust the
inputpaths to match your project's structure. -
Verify Your Blade Template: Make sure your Blade template is set up to include the Vite assets. In your main Blade file (e.g.,
resources/views/welcome.blade.php), include the Vite directives:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Laravel Vite</title> @vite(['resources/css/app.css', 'resources/js/app.js']) </head> <body> <h1>Welcome to Laravel with Vite</h1> </body> </html> -
Run Both Servers: You need to run both the Laravel development server and the Vite development server. Open two terminal windows or tabs and run the following commands:
-
In the first terminal, start the Laravel server:
php artisan serve -
In the second terminal, start the Vite development server:
npm run dev
-
-
Access Your Application: Open your browser and navigate to the URL provided by
php artisan serve, typicallyhttp://127.0.0.1:8000. You should see your Laravel application with Vite assets properly loaded.
By following these steps, you should be able to see your Laravel application instead of the Vite development server page. If you continue to experience issues, double-check your configuration files and ensure all paths and commands are correct.