Support the ongoing development of Laravel.io →
posted 3 months ago
Laravel

I am having an issue with hosting laravel projects, which is the problem that javascript, css, and svg files are not loaded, and the routing is not working.

They all works only during development.

The hosting service I used is Hostinger.

`<!DOCTYPE html>

<html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>BlogsFeed</title>
{{-- <link rel="stylesheet" href="{{ asset('CSS/frame.css') }}"/>
<link rel="stylesheet" href="{{ asset('CSS/feed.css') }}"/>
<link rel="stylesheet" href="{{ asset('CSS/login.css') }}"/>
<link rel="stylesheet" href="{{ asset('CSS/register.css') }}"/> --}}
@vite('resources/CSS/frame.css')
@vite('resources/CSS/feed.css')
@vite('resources/CSS/login.css')
@vite('resources/CSS/register.css')
</head> <body>
<div class="Navbar">
    <img alt="Logo" src="{{ asset('SVG/Logo.svg') }}"/>
    <nav>
        @if($pathname == "home")
        <a href="{{route('profile')}}">PROFILE</a>
        @elseif($pathname == "profile")
        <a href="{{route('home')}}">HOME</a>
        @elseif($pathname == "auth")
        <a href="{{route('profile')}}">PROFILE</a>
        <a href="{{route('home')}}">HOME</a>
        @endif
        <a href="{{route('setting')}}">SETTING</a>
        @auth
        <form action="{{route('logout')}}" method="POST">
            @csrf 
            <button type="submit">LOGOUT</button>
        </form>
        @endauth
    </nav>
    <svg version="1.1" viewBox="0 0 26.458 26.458" xmlns="http://www.w3.org/2000/svg">
        <g fill="#dcdcdc">
         <rect x=".22084" y=".22084" width="26.017" height="26.017" rx="1.3746" ry="1.276" fill-opacity=".5"/>
         <g stroke="#000" stroke-linecap="round">
          <path d="m6.1645 13.229h14.129" stroke-width=".52917"/>
          <path d="m6.1645 7.7766h14.129" stroke-width=".52917"/>
          <path d="m6.1645 18.824h14.129" stroke-width=".52917"/>
         </g>
        </g>
    </svg>
</div>

{{$slot}}

@auth
<img alt="AddPost" src="{{ asset('SVG/AddPost.svg') }}" class="AddPost"/>
@endauth

<script>
    const whether_Authenticated = @json(auth()->check());
</script>

<script src="https://cdn.jsdelivr.net/npm/gsap@3.12.7/dist/gsap.min.js"></script>
@vite('resources/JS/frame.js')
@vite('resources/JS/feed.js')
{{-- <script src="{{ asset('JS/frame.js') }}" type="module"></script>
<script src="{{asset('JS/feed.js')}}" type="module"></script> --}}
</body> </html>`

This is one of the blade files. It imports JS and CSS files using @vite() and asset() for SVG. SVG is stored in the public folder. JS and CSS are stored in the resources folder.

In Hostinger's file manager, I have moved the index.php and .htaccess from the public folder to the root directory. I have also configured the database credentials correctly in .env and config/database.php

What could be the error?

Last updated by @includecctype 3 months ago.
0

Make Sure You Update Your vite.config.js
import { defineConfig } from 'vite'; import laravel from 'laravel-vite-plugin'; import tailwindcss from '@tailwindcss/vite';

export default defineConfig({ plugins: [ laravel({ input: ['resources/css/app.css', 'resources/js/app.js'], refresh: true, }), tailwindcss(), ], });

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.