draw134
draw134

Reputation: 1187

Inertia returns 404 when deploying to hostinger

I have a laravel 10 project that utilizes inertia using vue 3. I transferred/copied all the public files in the public_html folder in the root directory (including the build folder). I also run npm run build on my local machine for asset building for production. When I access the site, there is this wierd /public path everytime I access then it shows this

Unable to locate file in Vite manifest: resources/js/Pages/404.vue.

the 404.vue must be rendered since I dont have a /public route defined. but still if i try another url its the same error.

In my app.blade.php i have this configuration

    @vite(['resources/js/app.js', "resources/js/Pages/{$page['component']}.vue"])
    @inertiaHead
    </head>
    <body class="font-sans antialiased">
        @inertia
    </body>

htaccess (public_html)

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
    
    <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteRule ^(.*)$ public/$1 [L]
    </IfModule>
</IfModule>

I also updated index.php and added the project folder name

Upvotes: 1

Views: 544

Answers (2)

Marcelo Sant&#39;Anna
Marcelo Sant&#39;Anna

Reputation: 135

I had a similar issue: I deployed to a shared hosting and I got the 404 for app.js and app.css when accessing the home page.

My solution was to change the content of .htaccess that was on the project root.

<IfModule mod_rewrite.c> 
  RewriteEngine on     
  RewriteRule ^$ public/ [L]     
  RewriteRule (.*) public/$1 [L] 
</IfModule>

Upvotes: 1

Octavian
Octavian

Reputation: 58

Delete hot file from the public root folder

Upvotes: 1

Related Questions