Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hosting a Vue js frontend and laravel backend(api routes) to a shared server?

I built a single page web app with vue js as the front-end library and laravel as the back-end framework. Its now time to host it on a shared hosting service and have not found any clear steps on how to do this successfully with the Api Routes of the loading as programmed.

I copied content of laravel public folder and build files of vue js to the public_html folder in shared hosting. Then it's loading the frontend without data from the backend. Should I have to use two separate ip addresses for backend and frontend or is it possible to use same shared hosting storage for deploy my Vue js frontend and laravel backend(api routes).

//index.php of laravel
<?php
require __DIR__.'/../jewelpack_app/vendor/autoload.php';
$app = require_once __DIR__.'/../jewelpack_app/bootstrap/app.php';
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
?>
//web.php of laravel routes
<?php
Route::get('/{any}', function(){
   return view('index');//pointing to the index file of the frontend
})->where('any', '.*');
?>
like image 366
Thiranjaya Munasinghe Avatar asked Nov 06 '22 15:11

Thiranjaya Munasinghe


1 Answers

Actually problem was with the my domain. I used my tempory webpage url for the hosting process. After I register my domain it all works fine. Thanks!

like image 173
Thiranjaya Munasinghe Avatar answered Nov 12 '22 13:11

Thiranjaya Munasinghe