I just uploaded my blog app to a test server which you can see here. When I click on post from the homepage I am able to view the single page using the slug url. However, from the single page, If I refresh the page it gives me a 404 page.
I had used something like the below for my users component:
Route::get('/admin/users{vue_capture?}', function () {
return view('admin');
})->where('vue_capture','[\/\w\.-]*');
This is how my routes.js looks like:
import VueRouter from 'vue-router';
import Admin from './components/Admin.vue';
import Homepage from './components/Homepage.vue';
import Subscriber from './components/subscriber/Main.vue';
import Single from './components/Single.vue';
import Categories from './components/Categories.vue';
let routes = [
{
path: '/',
component: Homepage
},
{
path: '/subscriber',
component: Subscriber
},
{
path: '/post/:slug',
name: 'post',
component: Single
},
{
path: '/categories/:slug',
component: Categories
}
];
export default new VueRouter({
mode: 'history',
routes
});
And my laravel routes are like this:
<?php
use App\User;
use App\Http\Resources\User as UserResource;
use App\Http\Resources\UserCollection;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
return view('homepage');
});
Auth::routes();
Route::get('/logout', 'Auth\LoginController@logout')->name('logout' );
Route::get('/home', 'HomeController@index')->name('home');
/************************************************************
API'S
************************************************************/
Route::get('/api/homeposts', 'HomePostsController@posts')->name('homeposts');
Route::resource('/api/users', 'AdminUsersController');
Route::resource('/api/posts', 'AdminPostsController');
Route::resource('/api/categories', 'AdminCategories');
Route::get('/api/loggedUser', 'AdminUsersController@loggUser')->name('singleUser');
Route::put('/api/updatedUser/{id}', 'AdminUsersController@updateUser')->name('singleUserUpdate');
Route::resource('/api/subscriber', 'SubscriberController');
/*Route::get('/admin/users{vue_capture?}', function () {
return view('admin');
})->where('vue_capture','[\/\w\.-]*');*/
/************************************************************
ADMIN ROUTES
************************************************************/
Route::group(['middleware'=>'admin'], function(){
Route::get('/admin/users', 'AdminUsersController@users')->name('allusers');
Route::resource('/admin/posts', 'AdminPostsController');
});
/************************************************************
SUBSCRIBER ROUTE
************************************************************/
Route::group(['middleware'=>'subscriber'], function(){
Route::get('/subscriber/{vue_capture?}', function () {
return view('homepage');
})->where('vue_capture','[\/\w\.-]*');
});
/**********************************************************/
Route::get('/single/post/{slug}', 'AdminPostsController@single');
But how exactly can I handle for the single post page?
Hope someone can help