Home  >  Q&A  >  body text

Laravel Inertia Vite

In production mode (on the server), my website gets the error in the Chrome console:

Uncaught (Promise) Error: Page not found: ./Pages/Posts/Show.vue

Additionally, the dashboard page does not update based on changes to the text and new pagination table that I introduced in local development.

Everything is fine locally, but pushing to Digital Ocean Server does not show the latest changes.

I checked the source code online and their original code is there. I can see the text, pagination table, and new routes changing. But they don't show up when I load the site. I suspect something to do with caching or the build process?

I've done it:

php artisan cache:clear

php artisan configuration: clear

php artisan view: clear

npm run build(new vite version assets)

Can anyone help?

shared documents:

Resources/js/app.js

import './bootstrap';
import '../css/app.css';

import { createApp, h } from 'vue';
import { createInertiaApp } from '@inertiajs/inertia-vue3';
import { InertiaProgress } from '@inertiajs/progress';
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
import { ZiggyVue } from '../../vendor/tightenco/ziggy/dist/vue.m';

const appName = window.document.getElementsByTagName('title')[0]?.innerText || 'Laravel';

createInertiaApp({
    title: (title) => `${title} - ${appName}`,
    resolve: (name) => resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob('./Pages/**/*.vue')),
    setup({ el, app, props, plugin }) {
        return createApp({ render: () => h(app, props) })
            .use(plugin)
            .use(ZiggyVue, Ziggy)
            .mount(el);
    },
});

InertiaProgress.init({ color: '#4B5563' });

Post controller

<?php

namespace AppHttpControllersPost;

use AppHttpControllersController;
use IlluminateHttpRequest;
use InertiaInertia;
use AppModelsPost;

class PostController extends Controller
{
    /**
     * Display all posts
     *
     * @return InertiaResponse
     */
    public function index(Request $request)
    {
        $posts = Post::paginate(10);
        
        return Inertia::render('Dashboard', ['posts' => $posts]);
    }


    /**
     * Display a post
     *
     * @return InertiaResponse
     */
    public function show(Request $request, $id)
    {
        $post = Post::findOrFail($id);

        return Inertia::render('Posts/Show', ['post' => $post]);
    }    
}

P粉262926195P粉262926195251 days ago418

reply all(1)I'll reply

  • P粉511985082

    P粉5119850822024-01-17 10:06:06

    This is a docker/nginx issue. Files generated by the application are not routed correctly, so static files from the original version are not replaced.

    I switched to using volumes to sync data between containers and it worked.

    reply
    0
  • Cancelreply