我用 vue js 作为前端库和 laravel 作为后端框架构建了一个单页 web 应用程序。现在是将它托管在共享托管服务上的时候了,但还没有找到任何明确的步骤来说明如何使用编程的加载的 Api 路由成功地做到这一点。
我将laravel公共文件夹的内容和vue js的构建文件复制到共享主机中的public_html文件夹中。然后它在没有来自后端的数据的情况下加载前端。我是否应该为后端和前端使用两个单独的 IP 地址,或者是否可以使用相同的共享托管存储来部署我的 Vue js 前端和 Laravel 后端(api 路由)。
//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', '.*');
?>
慕虎7371278
慕码人2483693