Search code examples
laraveldeploymentvitelaravel-9shared-hosting

Laravel 9 error "Vite manifest not found" on production server


I am deploying Laravel 9 project to shared hosting (without the ability to ssh into the server so I can't npm run build in the server) and I am getting this error:

Vite manifest not found at: laravel_project/public/build/manifest.json

I am using FileZilla to upload the project to the CPanel, I uploaded the public folder into public_html and configured the index.php file.

Before uploading the project i run npm run build locally on my localhost and everything works ok there.

Does anyone have a solution for this ?

I tried changing the APP_ENV=production but it didn't work.


Solution

  • so I found a solution for that which is:

    1. put all my local laravel files and folders including the public folder (of course after running composer install and npm run build locally) inside the public_html directory in the server

    2. now inside the server in public_html directory move the two files .htaccess and index.php of the public folder one level up in way so that the index.php file and the .htaccess file are directly inside the public_html directory (this way you don't have to include /public in your url but instead access the application directly when you visit your website)

    3. configure the content of index.php you just moved from public up to public_html in a way that its links point correctly to the content of the app inside public_html

    for example:

    __DIR__.'/../storage/framework/maintenance.php'

    becomes

    __DIR__.'/storage/framework/maintenance.php'

    so that the /.. is removed

    and the other links too like:

    __DIR__.'/../vendor/autoload.php'

    becomes

    __DIR__.'/vendor/autoload.php'

    and

    __DIR__.'/../bootstrap/app.php'

    becomes

    __DIR__.'/bootstrap/app.php'