将Laravel 7和Vue SPA应用程序部署到共享托管中

问题描述

专家, 我的应用程序具有Vue前端和Laravel 7后端。问题是,我无法重定向登录页面,它显示一个空白屏幕。所有Vue文件都位于resource / js文件夹中。前端和后端没有单独的文件夹。

“网络”标签

enter image description here

控制台日志

enter image description here

文件夹结构:

到目前为止我所做的:

AppServiceProvider.PHP

public function boot()
{
    $this->app->bind('path.public',function() {
      return base_path().'/../public_html/netlinkler/quickpack';
    });
}

app.js

require('./bootstrap');
window.Vue = require('vue')
import store from './store'
import router from './router'
import ViewUI from 'view-design';
import 'view-design/dist/styles/iview.css'; 
Vue.use(ViewUI);
import common from './common';
Vue.mixin(common);

Vue.component('mainapp',require('./components/mainapp.vue').default)


const app = new Vue({
    el: '#hmp',router,store
});

welcome.blade.PHP

<!DOCTYPE html>
<html lang="{{ str_replace('_','-',app()->getLocale()) }}">
    <head>
        <Meta charset="utf-8">
        <Meta name="viewport" content="width=device-width,initial-scale=1">

        <title>Delivery App</title>
        <link rel="stylesheet" href="{{asset('/css/all.css')}}">
    </head>
    <body>
       <div id="hmp">
         @if(Auth::guard('employee')->check())
           <mainapp :user="{{Auth::guard('employee')->user()}}"></mainapp>
         @else
           <mainapp :user="false"></mainapp>
         @endif
       </div>
    </body>

<script src="{{ mix('/js/app.js') }}"> </script>
</html>

EmployeeControler.PHP

public function index(Request $request){
        
               if(!Auth::guard('employee')->check() && $request->path() != 'login'){
                  return redirect('/login');
               }
        
               if(!Auth::guard('employee')->check() && $request->path() == 'login'){
                 return view('welcome');
               }
        
               return view('welcome');
}

web.PHP

Route::get('/','EmployeesController@index');
Auth::routes();

router.js

    const routes = [
    
        {
            path: '/home',component: home 
        },{
            path: '/login',component: login 
        }
    ]

export default new Router({
    mode: "history",baseurl: "/api/v1",base: 'deliverywebapp',routes
})

解决方法

您需要将应用程序文件夹添加到路由路径

或者您可以添加基本路径

导出默认的新路由器({

mode: "history",baseurl: "/api/v1",base: 'deliverywebapp',

常量路由= [

{
    path: '/home',component: home 
},{
    path: '/login',component: login 
}

]

})

导出默认的新路由器({

mode: "history",

常量路由= [

{
    path: '/deliverywebapp/home',{
    path: '/deliverywebapp/login',component: login 
}

]

})